From patchwork Fri Jul 3 12:04:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 229073 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp2327950ilg; Fri, 3 Jul 2020 05:06:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzJPX91pSjsdMq4LHxAWuLMn/DN6m40LC6//zlaqw9ajOIcBSBQZSgLsNy4XpeMcW9AiUp X-Received: by 2002:a05:6402:3d0:: with SMTP id t16mr38973074edw.287.1593777962076; Fri, 03 Jul 2020 05:06:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593777962; cv=none; d=google.com; s=arc-20160816; b=A5ba3WHP0+I92h8SPh6AhM8ghGSeagHM2qZcJPjilfpOzU1/wXaBVpU03mGvqJcFGC jH6jT3176buEZp+AqoP7KWXLIVE2aupE4T3ilvmnhgU4F4RXJvv0T0FrUSBdycRnGoH7 3P3lmKl4/t6Os3V1SCDnZYgDVyNXnWZ1+/eYpdWErAmQD+FDKkzVNWfQNFospshbfdcQ h/ZXBPQAkqqJwQT3sdcl/xltaXDRz/Us2u3yNutQrcuUDxHyI2swQxhZHd8VQwWWAmri ur43DmxblojPz54HYDYFfzZ9c6tpZdBU9BnfvpcBHCpGdAAJWgMOf1WbcNt6d30heVJV RbRQ== 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=u+4tCdRoAPKsmK2WO2xiikNWcqmj5ucF/wlwcbbvRoBxk3kFuj1qUJZ7yjsZkARk57 c+wIYT9VUu5YvIxFQ9zBp3jKhN9jwRaZVcfwwe2Jyr9xyZKWum3JYyNlp25rFimdKg5q YOBpT50mr/JjHbiJ989s1LRZCsBm8sJbTJaMS0W/whHCHw5aIhbOgWyisste/w/Fc8ZQ L/dWAE0sbw1WD2V7jyNzIylawlMTJSUaFSTfMnixwxzGvaU20edYPGAHBOfJD7WiRDMS OEI34bCqvFFTVqJszomiSvQ0O3ihfKOQ5gG5M1tQGQDWYrdXIM67fZHf/7ES7Xc+AShL pPZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ZpxkDVXT; 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 k13si7478178ejq.296.2020.07.03.05.06.01 for ; Fri, 03 Jul 2020 05:06:02 -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=ZpxkDVXT; 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 S1726108AbgGCMGB (ORCPT ); Fri, 3 Jul 2020 08:06:01 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:42092 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbgGCMGB (ORCPT ); Fri, 3 Jul 2020 08:06:01 -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 063C4K1A000964; Fri, 3 Jul 2020 07:04:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1593777860; bh=G4wnnj72ALl51c7aAtn+twNQ2gnUnkuWdD4xZPMkDIs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ZpxkDVXTdUupeQsRZnwHUKQTbCGi3vzBauisDrGAFo7H0lY6+IKULRhlEmy38I7wz T4n0iNWGJ57b+kkObhx0i5pHnNImaH9Oj1aLMIoXtxrcXvhZtGh7V9TpiGNsoTdC5U QWuBNaSlVD5WaamHtBnBjZV/4d0GPlYairhNC0dM= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 063C4JnN078667 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jul 2020 07:04:20 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) 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; Fri, 3 Jul 2020 07:04:19 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE111.ent.ti.com (10.64.6.32) 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, 3 Jul 2020 07:04:19 -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 063C4Fkf109800; Fri, 3 Jul 2020 07:04:18 -0500 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 1/5] watchdog: use __watchdog_ping in startup Date: Fri, 3 Jul 2020 15:04:02 +0300 Message-ID: <20200703120406.7092-2-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703120406.7092-1-t-kristo@ti.com> References: <20200703120406.7092-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; From patchwork Fri Jul 3 12:04:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 229076 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp2328141ilg; Fri, 3 Jul 2020 05:06:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUrEUckfCMbIkDpX8dBi52IZV2N26Pr+T+yOm1CjW9G+AyjvkE+07JszgGNL947im0MO9q X-Received: by 2002:a05:6402:1bdd:: with SMTP id ch29mr29356435edb.134.1593777972165; Fri, 03 Jul 2020 05:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593777972; cv=none; d=google.com; s=arc-20160816; b=zhDSNncbozhGt1bpsxSg1yHyXm1S8yWsOEpjamlB7E4bF3M71pob9aVrpx3y7q8TrX HwqjtL8x8xuy+UeCFPE2sYcgxbWCLGB4o3m/jcU0yiN9IsYPjm7xSIAjlCLuUYdVyYCm TWypcTEitpSyJ33UyDJmr/wSdSHvVBDyDmCS5c+Q5zqni8FDkWcM4nU54vdBhnjfjPYu PGglmP24oNV2tX4fjTSNt3GrNdcEzkwfqPw3Fn3cxhmmNd8MDcCE4EdV8UjbFDhNXgxR 2KYCDsuiZIRHMmAU8HefezcY9eNip66thAuQfkIU7Mc8M6SvESouJ1N0poKwY0bKgUrw uLlA== 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=VKk0r+2wsoL3MjGVaSjznFzV0l/708UsUjZION0spOs=; b=kCWfE9Geghxx3KTJWJdtwwmxa27+WnVtOhUjMm53ies8j0o/7hZCWSphRAz/D9hb3F f6w9FWv3ifcpzQMpWxU2NZtqJ9aPZoi023c145oqZbrmh5vRkr8ffwu/95LsD8X+yLqQ 3Xi845Depgnp3C+oXaIC00owpAjmjQh8u1Ipd7XFkJw7Tb+36gTgkw+vDDWqJjGw9no7 3bnnjp8pFBLdDgYGaLm9+6h0rZVH6rFj0fl/a4GaYYMxdgOrjUb4pKPR5acabtSJ0zeK JlSwV2bVL0GdvG1Dl4EvsGMcUYbqaaqa/+N92JmKW5TpW39vC3uuAET+29T5/YeTVoOr p9sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=vJak7I7p; 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 v8si7728873edr.557.2020.07.03.05.06.12 for ; Fri, 03 Jul 2020 05:06:12 -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=vJak7I7p; 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 S1726318AbgGCMGI (ORCPT ); Fri, 3 Jul 2020 08:06:08 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:59096 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726309AbgGCMGI (ORCPT ); Fri, 3 Jul 2020 08:06:08 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 063C4LFa110388; Fri, 3 Jul 2020 07:04:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1593777861; bh=VKk0r+2wsoL3MjGVaSjznFzV0l/708UsUjZION0spOs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=vJak7I7pdR9dVnLtJNJMzzOnoT3Co0g30uf7HmTWOh+Edp8tM75ysPDea8zbs13Ga bYNf6ELJjrcXMHuHbjCUNeUXJT18Mcmmo/3ohx6b0M1f1lZnjSC2Hp5H+DnF5h57p/ /aSL6wKGXqUyICfH/1syS4H7I9mM6As2D6gOqEWc= Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 063C4LDl068734 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jul 2020 07:04:21 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) 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; Fri, 3 Jul 2020 07:04:20 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE111.ent.ti.com (10.64.6.32) 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, 3 Jul 2020 07:04:20 -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 063C4Fkg109800; Fri, 3 Jul 2020 07:04:19 -0500 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 2/5] watchdog: add support for adjusting last known HW keepalive time Date: Fri, 3 Jul 2020 15:04:03 +0300 Message-ID: <20200703120406.7092-3-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703120406.7092-1-t-kristo@ti.com> References: <20200703120406.7092-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 Certain watchdogs require the watchdog only to be pinged within a specific time window, pinging too early or too late cause the watchdog to fire. In cases where this sort of watchdog has been started before kernel comes up, we must adjust the watchdog keepalive window to match the actually running timer, so add a new driver API for this purpose. Signed-off-by: Tero Kristo --- drivers/watchdog/watchdog_dev.c | 23 +++++++++++++++++++++++ include/linux/watchdog.h | 2 ++ 2 files changed, 25 insertions(+) -- 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 bc1cfa288553..5848551cf29d 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -1138,6 +1138,29 @@ void watchdog_dev_unregister(struct watchdog_device *wdd) watchdog_cdev_unregister(wdd); } +/* + * watchdog_set_last_hw_keepalive: set last HW keepalive time for watchdog + * + * Adjusts the last known HW keepalive time for a watchdog timer. + * This is needed in case where watchdog has been started before + * kernel by someone like bootloader, and it can't be pinged + * immediately. This adjusts the watchdog ping period to match + * the currently running timer. + */ +int watchdog_set_last_hw_keepalive(struct watchdog_device *wdd, + unsigned int last_ping_ms) +{ + struct watchdog_core_data *wd_data = wdd->wd_data; + ktime_t now; + + now = ktime_get(); + + wd_data->last_hw_keepalive = ktime_sub(now, ms_to_ktime(last_ping_ms)); + + return __watchdog_ping(wdd); +} +EXPORT_SYMBOL_GPL(watchdog_set_last_hw_keepalive); + /* * watchdog_dev_init: init dev part of watchdog core * diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index 1464ce6ffa31..9b19e6bb68b5 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h @@ -210,6 +210,8 @@ extern int watchdog_init_timeout(struct watchdog_device *wdd, extern int watchdog_register_device(struct watchdog_device *); extern void watchdog_unregister_device(struct watchdog_device *); +int watchdog_set_last_hw_keepalive(struct watchdog_device *, unsigned int); + /* devres register variant */ int devm_watchdog_register_device(struct device *dev, struct watchdog_device *); From patchwork Fri Jul 3 12:04:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 229079 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp2328577ilg; Fri, 3 Jul 2020 05:06:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcbodAlE8TIjoKrTkGfgQksAdph0aowu41TTaB5cDtLswUV6g37ji1EL1zZRKE82h/D+fw X-Received: by 2002:a17:906:1e83:: with SMTP id e3mr16989561ejj.7.1593777999821; Fri, 03 Jul 2020 05:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593777999; cv=none; d=google.com; s=arc-20160816; b=z7Q03KvK8apbUuBnAsaAB60FlHsekh+FsXz/trEPD8Zjp1Kyar1tqvpS70JKd+GAeM vpTkwtREtYD1Ov7a9YA2OtO3pYw3wNzkH2hWi8M7lI0kk+xFyePaFb5vWV2pt0ezB5U2 Shmm4WTU5WvPFe3pkPp1qtbD+gtmXnmC3mzJjXdH4XZxb0uqWlbjpyraexWzpHdE7HVs JC6m3N/VH/mj/IykhWwjvEYcU15WwBLvBH+zxugJpa0KnnPnvL9AceKX6c2XK3i/uaat fiFlJZOLG9yXO23iLc9lkEPX0JuiJOkgZ30DYb2xaUtBYAju6Ukk99nrOMiCd23rZ0gu WO6g== 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=pBWKeVtNSU7GI6pzg2P/xGJf2y+QgqUeEihFsNb6fzc=; b=ogaYJunZBEat5IsNxG2yEpR687cKBZOXaGNcalmWIqKBR2NpjlXvtN1/5+hzVYsTgb P7HWbha7tSDZCwjF1iLgFguezyf4DBJ6ZrH6b1LwdKBwmP4PmFoP4kaf8mdJC5P3dnUG j73FXqVVomxg57hverVC0stxsuiyn3zYf4rj3F7pzmUwzEqSsyb4iHLPqof1flg3w8J8 y0cSdNY60JuO9DI7AX/WTGUnul4nprffKlzqr9mAGsInc+ndMq8/eyslRrxOPhs+gIPF HhKsXfwFumV2Si2+w+expZLGo+KnNkCwomhan3j/Mei5KsUPWQxg5fk1KJhzNZqWIdmg tdsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=BXuToblN; 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 bs18si7937294edb.517.2020.07.03.05.06.39 for ; Fri, 03 Jul 2020 05:06:39 -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=BXuToblN; 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 S1726147AbgGCMGf (ORCPT ); Fri, 3 Jul 2020 08:06:35 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:38624 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726276AbgGCMGe (ORCPT ); Fri, 3 Jul 2020 08:06:34 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 063C4SDC060620; Fri, 3 Jul 2020 07:04:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1593777868; bh=pBWKeVtNSU7GI6pzg2P/xGJf2y+QgqUeEihFsNb6fzc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=BXuToblN53pfQ4dVaolqRJ7Z807JPwf4LstxUHVrhhGrkhC+0wnSwqVqJ8B+7cdel VG+EyhEImm8pimI3dW0fpdiUzDs/bUHklE7j48yl/+ogSAQc2mFwB6tUF+x4O7I0VD uEys7ejify5ClVmYi953Ag+SRLET2pcD71MIEqOk= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 063C4NcE078738 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jul 2020 07:04:28 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Fri, 3 Jul 2020 07:04:22 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) 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 via Frontend Transport; Fri, 3 Jul 2020 07:04:22 -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 063C4Fkh109800; Fri, 3 Jul 2020 07:04:21 -0500 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 3/5] watchdog: rti-wdt: add support for window size configuration Date: Fri, 3 Jul 2020 15:04:04 +0300 Message-ID: <20200703120406.7092-4-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703120406.7092-1-t-kristo@ti.com> References: <20200703120406.7092-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 RTI watchdog can support different open window sizes. Add support for these and add a new module parameter to configure it. The default open window size for the driver still remains at 50%. Also, modify the margin calculation logic a bit for 32k source clock, instead of adding a margin to every window config, assume the 32k source clock is running slower. Signed-off-by: Tero Kristo --- drivers/watchdog/rti_wdt.c | 112 +++++++++++++++++++++++++++++++------ 1 file changed, 95 insertions(+), 17 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/rti_wdt.c b/drivers/watchdog/rti_wdt.c index d456dd72d99a..110bfc8d0bb3 100644 --- a/drivers/watchdog/rti_wdt.c +++ b/drivers/watchdog/rti_wdt.c @@ -19,7 +19,8 @@ #include #include -#define DEFAULT_HEARTBEAT 60 +#define DEFAULT_HEARTBEAT 60 +#define DEFAULT_WINDOWSIZE 50 /* Max heartbeat is calculated at 32kHz source clock */ #define MAX_HEARTBEAT 1000 @@ -35,9 +36,13 @@ #define RTIWWDRX_NMI 0xa -#define RTIWWDSIZE_50P 0x50 +#define RTIWWDSIZE_50P 0x50 +#define RTIWWDSIZE_25P 0x500 +#define RTIWWDSIZE_12P5 0x5000 +#define RTIWWDSIZE_6P25 0x50000 +#define RTIWWDSIZE_3P125 0x500000 -#define WDENABLE_KEY 0xa98559da +#define WDENABLE_KEY 0xa98559da #define WDKEY_SEQ0 0xe51a #define WDKEY_SEQ1 0xa35c @@ -48,7 +53,8 @@ #define DWDST BIT(1) -static int heartbeat; +static int heartbeat = DEFAULT_HEARTBEAT; +static u32 wsize = DEFAULT_WINDOWSIZE; /* * struct to hold data for each WDT device @@ -62,34 +68,93 @@ struct rti_wdt_device { struct watchdog_device wdd; }; +static int rti_wdt_convert_wsize(void) +{ + if (wsize >= 50) { + wsize = RTIWWDSIZE_50P; + } else if (wsize >= 25) { + wsize = RTIWWDSIZE_25P; + } else if (wsize > 12) { + wsize = RTIWWDSIZE_12P5; + } else if (wsize > 6) { + wsize = RTIWWDSIZE_6P25; + } else if (wsize > 3) { + wsize = RTIWWDSIZE_3P125; + } else { + pr_err("%s: bad windowsize: %d\n", __func__, wsize); + return -EINVAL; + } + + return 0; +} + +static int rti_wdt_setup_hw_hb(struct watchdog_device *wdd) +{ + /* + * RTI only supports a windowed mode, where the watchdog can only + * be petted during the open window; not too early or not too late. + * The HW configuration options only allow for the open window size + * to be 50% or less than that. + */ + switch (wsize) { + case RTIWWDSIZE_50P: + /* 50% open window => 50% min heartbeat */ + wdd->min_hw_heartbeat_ms = 500 * heartbeat; + break; + + case RTIWWDSIZE_25P: + /* 25% open window => 75% min heartbeat */ + wdd->min_hw_heartbeat_ms = 750 * heartbeat; + break; + + case RTIWWDSIZE_12P5: + /* 12.5% open window => 87.5% min heartbeat */ + wdd->min_hw_heartbeat_ms = 875 * heartbeat; + break; + + case RTIWWDSIZE_6P25: + /* 6.5% open window => 93.5% min heartbeat */ + wdd->min_hw_heartbeat_ms = 935 * heartbeat; + break; + + case RTIWWDSIZE_3P125: + /* 3.125% open window => 96.9% min heartbeat */ + wdd->min_hw_heartbeat_ms = 969 * heartbeat; + break; + + default: + pr_err("%s: Bad watchdog window size!\n", __func__); + return -EINVAL; + } + + return 0; +} + static int rti_wdt_start(struct watchdog_device *wdd) { u32 timer_margin; struct rti_wdt_device *wdt = watchdog_get_drvdata(wdd); + int ret; /* set timeout period */ - timer_margin = (u64)wdd->timeout * wdt->freq; + timer_margin = (u64)heartbeat * wdt->freq; timer_margin >>= WDT_PRELOAD_SHIFT; if (timer_margin > WDT_PRELOAD_MAX) timer_margin = WDT_PRELOAD_MAX; writel_relaxed(timer_margin, wdt->base + RTIDWDPRLD); - /* - * RTI only supports a windowed mode, where the watchdog can only - * be petted during the open window; not too early or not too late. - * The HW configuration options only allow for the open window size - * to be 50% or less than that; we obviouly want to configure the open - * window as large as possible so we select the 50% option. To avoid - * any glitches, we accommodate 5% safety margin also, so we setup - * the min_hw_hearbeat at 55% of the timeout period. - */ - wdd->min_hw_heartbeat_ms = 11 * wdd->timeout * 1000 / 20; + ret = rti_wdt_convert_wsize(); + if (ret) + return ret; + + ret = rti_wdt_setup_hw_hb(wdd); + if (ret) + return ret; /* Generate NMI when wdt expires */ writel_relaxed(RTIWWDRX_NMI, wdt->base + RTIWWDRXCTRL); - /* Open window size 50%; this is the largest window size available */ - writel_relaxed(RTIWWDSIZE_50P, wdt->base + RTIWWDSIZECTRL); + writel_relaxed(wsize, wdt->base + RTIWWDSIZECTRL); readl_relaxed(wdt->base + RTIWWDSIZECTRL); @@ -169,6 +234,14 @@ static int rti_wdt_probe(struct platform_device *pdev) return -EINVAL; } + /* + * If watchdog is running at 32k clock, it is not accurate. + * Adjust frequency down in this case so that we don't pet + * the watchdog too often. + */ + if (wdt->freq > 30000 && wdt->freq < 32768) + wdt->freq = 30000; + pm_runtime_enable(dev); ret = pm_runtime_get_sync(dev); if (ret) { @@ -251,5 +324,10 @@ MODULE_PARM_DESC(heartbeat, __MODULE_STRING(MAX_HEARTBEAT) ", default " __MODULE_STRING(DEFAULT_HEARTBEAT)); +module_param(wsize, uint, 0); +MODULE_PARM_DESC(wsize, + "Watchdog open window size in percentage from 3 to 50, " + "default " __MODULE_STRING(DEFAULT_WINDOW_SIZE)); + MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:rti-wdt"); From patchwork Fri Jul 3 12:04:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 229074 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp2328028ilg; Fri, 3 Jul 2020 05:06:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPOq2mr7n/UP0CtNekpjlUyzOZP91I45NF5BJ8xrXHDP7pNcPD93tgOQCj+MinH6/BUV6U X-Received: by 2002:a17:906:c453:: with SMTP id ck19mr5957937ejb.185.1593777966011; Fri, 03 Jul 2020 05:06:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593777966; cv=none; d=google.com; s=arc-20160816; b=pYJUCPVdnWf8SbV6Eo8YGq7bV1tGLXGAcS9vLYFittnQbIH1ncYcxFjNHwZJI4qyA/ wyUREdjEPRn7e88nuoegyi1VyJshX79RKo5SVhpGpXNFUUmz1zQ8P4k5vAtnEUIP2Nq3 rXozD63NzqbO6fehsfD13rmFkz5kXcwFTYSHnyBsXcji+/yNp2K+Tq5A2COjJwPx4pfe XgdaLoMCTmo2zo1hDtFVgc3vEBnnre824ht/LMph060Y6Fs0ZbPnlmfP2oS7GrP/73rE QJypCl1tzN6i3vBfrPOc/gfh6VOvEAlSWtWdkBOI1gRtC7Y9YBb8FYt2AOZoo9FlxxGZ 7Vag== 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=VggTboeXSUmk45kulNtqvR4NEUHjkR5OBNU73J+87dM=; b=y/QXQuI4own3/3iu3i+QYIwS7Na5zCWHJXcF0uDteCOcAXIGSZykVLEJjc5l+IOVkK K+ezwZuTR4bYyMtkcml72avKOfVOo6hD36zYMpMl5EnsboN13EoB6xqTy8k5svyoLkA2 HMveXkxY3qdFDO67Iv1xwf1Rdx908RscqpAa9L9ufpVp8DW1gvvdwY+OnBgO/KqKGn7+ aD1PRE2oQOMVt0tVBAzyooWMUTU7exZCvAXIkkMQTWKsKIIM3ZDLwhQ5IJQlPYublkgb PemDGRpEBdcDxM4FMa7/MwMqS2hq/a7xILPx0QErof2QB5uazuGi9zoZK2JCbbvywYTW +iOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=QfMjefPb; 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 ss22si8470533ejb.530.2020.07.03.05.06.05 for ; Fri, 03 Jul 2020 05:06:06 -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=QfMjefPb; 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 S1726147AbgGCMGF (ORCPT ); Fri, 3 Jul 2020 08:06:05 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:42098 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbgGCMGE (ORCPT ); Fri, 3 Jul 2020 08:06:04 -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 063C4O3s001021; Fri, 3 Jul 2020 07:04:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1593777864; bh=VggTboeXSUmk45kulNtqvR4NEUHjkR5OBNU73J+87dM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=QfMjefPb1cyKZPpn+KxwkKBvejB/DmWP/9j+Huq0rnDYP55f2MA8q1uRqH3M8LNF1 59k+6laUz3o6W76ogQoUtxsOR9tBojgTgaxdW1ewOAu9dnrfhBJi9ywzT4fP1X+V1+ Lf4qxSdcqaTFa+oWikVN4MM7kpSMnzTFp+6d92YI= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 063C4OLN065867; Fri, 3 Jul 2020 07:04:24 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Fri, 3 Jul 2020 07:04:24 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE102.ent.ti.com (10.64.6.23) 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, 3 Jul 2020 07:04:24 -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 063C4Fki109800; Fri, 3 Jul 2020 07:04:22 -0500 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 4/5] watchdog: rti-wdt: attach to running watchdog during probe Date: Fri, 3 Jul 2020 15:04:05 +0300 Message-ID: <20200703120406.7092-5-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703120406.7092-1-t-kristo@ti.com> References: <20200703120406.7092-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 If the RTI watchdog is running already during probe, the driver must configure itself to match the HW. Window size and timeout is probed from hardware, and the last keepalive ping is adjusted to match it also. Signed-off-by: Tero Kristo --- drivers/watchdog/rti_wdt.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 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/rti_wdt.c b/drivers/watchdog/rti_wdt.c index 110bfc8d0bb3..987e5a798cb4 100644 --- a/drivers/watchdog/rti_wdt.c +++ b/drivers/watchdog/rti_wdt.c @@ -213,6 +213,7 @@ static int rti_wdt_probe(struct platform_device *pdev) struct watchdog_device *wdd; struct rti_wdt_device *wdt; struct clk *clk; + u32 last_ping = 0; wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) @@ -258,11 +259,8 @@ static int rti_wdt_probe(struct platform_device *pdev) wdd->min_timeout = 1; wdd->max_hw_heartbeat_ms = (WDT_PRELOAD_MAX << WDT_PRELOAD_SHIFT) / wdt->freq * 1000; - wdd->timeout = DEFAULT_HEARTBEAT; wdd->parent = dev; - watchdog_init_timeout(wdd, heartbeat, dev); - watchdog_set_drvdata(wdd, wdt); watchdog_set_nowayout(wdd, 1); watchdog_set_restart_priority(wdd, 128); @@ -274,12 +272,34 @@ static int rti_wdt_probe(struct platform_device *pdev) goto err_iomap; } + if (readl(wdt->base + RTIDWDCTRL) == WDENABLE_KEY) { + u32 time_left; + + set_bit(WDOG_HW_RUNNING, &wdd->status); + time_left = rti_wdt_get_timeleft(wdd); + heartbeat = readl(wdt->base + RTIDWDPRLD); + heartbeat <<= WDT_PRELOAD_SHIFT; + heartbeat /= wdt->freq; + + wsize = readl(wdt->base + RTIWWDSIZECTRL); + ret = rti_wdt_setup_hw_hb(wdd); + if (ret) + goto err_iomap; + + last_ping = -(time_left - heartbeat) * 1000; + } + + watchdog_init_timeout(wdd, heartbeat, dev); + ret = watchdog_register_device(wdd); if (ret) { dev_err(dev, "cannot register watchdog device\n"); goto err_iomap; } + if (last_ping) + watchdog_set_last_hw_keepalive(wdd, last_ping); + return 0; err_iomap: From patchwork Fri Jul 3 12:04:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 229077 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp2328505ilg; Fri, 3 Jul 2020 05:06:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJj1c4ivJWaWpaeS/y5E8aPHSUKJkK/1P6vN7zMaUB+K3BFQjINUbJlr0uC1idnYPbGkuj X-Received: by 2002:a17:906:a242:: with SMTP id bi2mr27006407ejb.243.1593777993872; Fri, 03 Jul 2020 05:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593777993; cv=none; d=google.com; s=arc-20160816; b=UHUiC+31oT7Hkc9fbCOwbdg4xM5CjCLR9BV9R+9b8F5E6Vp4oSyVCUcKVOOUpBFTa1 uXy4m5CasuD6Cfas+itZvvcpKyf6mMM+4C5OP3DJ7qJzv/SIz/ii/wogzpZ01MgrtWxd 6j4JNPMSvL5ywfw1AkRNyQqwnAL8UCg665GfsNBGzESUViOVgM6lLK4hDjLsOlDsZDsm I0+iLS77p35iti7Ms7//wfNucho0l4M87pfD4KQflF5V1rwNoYlbOIdsk6JumpNDjWfr ZQjXxsQIF21qxVZRNXzAFpSjyws4Wp0cmW2McQc7qJo6X4MGXHishm0pbK9zd1icobRg 4CFQ== 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=yErUdsaQq1DKXS4cIgWJyC1B7C7lxDSI9EbVYJz4ysc=; b=fpxyWT5V6ylKgEf0N77F/nd5aFInUCTnwYpWbePFLdWXqZfGTByUOzhBK7GKcfxB9g +IlxgyzJKLogJoHO2vVlJSwAIjPSI5sBbkQbUUUfSUSvFEDY7j1w5PhsajnYi1+VokBF daNk+pB4anU4XGJNX9a2uQ5Sik2hGo+NyifCTtQNmX5AkviAVOGFDV9X6lDPRNKlaxAs fI1SES+C7GE+p09KmTiIRpjvQzP1ZdHkxtWy72zLVCr/9UdgKerEdKPhLtUqihjATHT5 /hBwUgYLkcMfqPb6QrOW0N0F895/sTRqfdFFg6759LyZCFLGBmyJBZdFjMmD0PtTg1HS wn+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=VGlo6T2w; 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 c25si7550692ejd.178.2020.07.03.05.06.33 for ; Fri, 03 Jul 2020 05:06:33 -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=VGlo6T2w; 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 S1726353AbgGCMGd (ORCPT ); Fri, 3 Jul 2020 08:06:33 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:38622 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726147AbgGCMGd (ORCPT ); Fri, 3 Jul 2020 08:06:33 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 063C4Qo9060614; Fri, 3 Jul 2020 07:04:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1593777866; bh=yErUdsaQq1DKXS4cIgWJyC1B7C7lxDSI9EbVYJz4ysc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=VGlo6T2wwJMA5CfjQlpalll3QXV43UhUY6sP9jtb2MqG/lWkRK34lRsWmTcwoib2r u0VjP1ZcYiuPNJl7eFPKDq8gTAv65mOQPuJfiKQBwYZKE2emDFx8rSuvSh6o/GYNVc rHBp//bAVYRNqy4qOCuIp3o0qiS+AbTCPweNDuvk= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 063C4QcC078799 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jul 2020 07:04:26 -0500 Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Fri, 3 Jul 2020 07:04:25 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE114.ent.ti.com (157.170.170.25) 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, 3 Jul 2020 07:04:25 -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 063C4Fkj109800; Fri, 3 Jul 2020 07:04:24 -0500 From: Tero Kristo To: , , CC: , Subject: [PATCHv2 5/5] watchdog: rti-wdt: balance pm runtime enable calls Date: Fri, 3 Jul 2020 15:04:06 +0300 Message-ID: <20200703120406.7092-6-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200703120406.7092-1-t-kristo@ti.com> References: <20200703120406.7092-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 PM runtime should be disabled in the fail path of probe and when the driver is removed. Fixes: 2d63908bdbfb ("watchdog: Add K3 RTI watchdog support") Signed-off-by: Tero Kristo --- drivers/watchdog/rti_wdt.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki Reviewed-by: Guenter Roeck diff --git a/drivers/watchdog/rti_wdt.c b/drivers/watchdog/rti_wdt.c index 987e5a798cb4..7007445da80b 100644 --- a/drivers/watchdog/rti_wdt.c +++ b/drivers/watchdog/rti_wdt.c @@ -304,6 +304,7 @@ static int rti_wdt_probe(struct platform_device *pdev) err_iomap: pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); return ret; } @@ -314,6 +315,7 @@ static int rti_wdt_remove(struct platform_device *pdev) watchdog_unregister_device(&wdt->wdd); pm_runtime_put(&pdev->dev); + pm_runtime_disable(&pdev->dev); return 0; }