Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3808115rwa; Tue, 23 Aug 2022 10:24:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR7uraSVCKA6Wrc1d8Ww1Uh3ZpzV190wsT5O6N3NEyhYhMhz9Km6yMQ+XEh+q+Ar4hAuWXfT X-Received: by 2002:a17:902:ca8d:b0:172:c872:15e with SMTP id v13-20020a170902ca8d00b00172c872015emr18876214pld.156.1661275494412; Tue, 23 Aug 2022 10:24:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661275494; cv=none; d=google.com; s=arc-20160816; b=Adf18K/9MhhGMaHK0D00MuNJ7SyDal/O/hzpwpZbLsve+24iJBszu2N5qUJjaOnejI ud6KLOw1OkyKVSva+/oK/5UqkmK/okmJDabVS30CueYDN/SSiBrPYZnGaG6fPLtbZYt/ uQmiKpbbgJr5jv0uaL6Y9EX4m2bLbufLQ+EBLKwFS/JmXDq60Ev1MfGV8PBZQA5gCp2S j1OW8rgX7uEy/jNEs67E1IgVXVngduQFcYr6EH5bCnFCTEiDQAiUbMJ1tlKEi5O3ZJI+ J+HRnEtOHu0fs11wG1NOExnXg40w+a6/bOFXqhfSlg5+inqxQBrbeXcUtj6PlkGHZtO0 37hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=4fpc7DDr1cBcY0zp8LDLF5xyNGxLDQvc9n2jefed/40=; b=B5jAO0fkHlI+aUhhdoNIBhkjn1CFJgcUphGTf6ZhdW5Tng9cBeN8PxhUtB9qPhvjEx lulZuEQi+4b3/sgx9nfMqDJrU75Y8BQ0LOFz+UTpJ81GdEl17eSgPHsFHPddb8VgVEQA ioiPmQw0csG99dq/nLQdftp2+g/smbAy8U0jHj4iz8y1P1mfRwMh60G9qKSxZjnu7ker 3ZlFrMomlyL//YkqJdpAdbZVBWosTs+31pAo1nUub4ZGaRCMU4ZIVUIPxbo1hTn8N/53 300qKjjnQNZ8evFqOOHrZkU5uowsGGF4paCs6AhLAxN+eNzHcGJnon2/ZHkVaUN0zEWA WG6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=gMmMz33Y; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020a170902f60e00b00170cde7d287si15909687plg.421.2022.08.23.10.24.43; Tue, 23 Aug 2022 10:24:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=gMmMz33Y; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233741AbiHWRTH (ORCPT + 99 others); Tue, 23 Aug 2022 13:19:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233595AbiHWRSl (ORCPT ); Tue, 23 Aug 2022 13:18:41 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 703001175DD; Tue, 23 Aug 2022 06:47:17 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 27835336D1; Tue, 23 Aug 2022 13:47:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1661262436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4fpc7DDr1cBcY0zp8LDLF5xyNGxLDQvc9n2jefed/40=; b=gMmMz33YhNuP4+oZY66Y1T6EiVIn8JzM1/WhcH0ryNzzYAoc7ZwsdOipjBEkgwhFJb0pA9 2HcOVNC02ke1bTqW4asQMRCeWrvHsOpvPF1DTd+r80/zSQfdqamA7mQYP9UHBTJplifamL ehSoEQn2Niv6E7Dhuwdnj0m6sC4wnjk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1661262436; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4fpc7DDr1cBcY0zp8LDLF5xyNGxLDQvc9n2jefed/40=; b=NEhfsqR3We1uxi6BxQn6ghoeGPC14lmwm9Jo8Rn1QmEKt9J9SdZmRf+H+BiEF7IbpJC5jP Bgh/jIWF83VTOtAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DF00A13A89; Tue, 23 Aug 2022 13:47:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 03mGNGPaBGPrbQAAMHmgww (envelope-from ); Tue, 23 Aug 2022 13:47:15 +0000 Date: Tue, 23 Aug 2022 15:47:13 +0200 From: Jean Delvare To: linux-watchdog@vger.kernel.org, LKML Cc: Mika Westerberg , Guenter Roeck , Wim Van Sebroeck , "Rafael J. Wysocki" , Liu Xinpeng Subject: [PATCH v3] watchdog: wdat_wdt: Set the min and max timeout values properly Message-ID: <20220823154713.023ee771@endymion.delvare> Organization: SUSE Linux X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The wdat_wdt driver is misusing the min_hw_heartbeat_ms field. This field should only be used when the hardware watchdog device should not be pinged more frequently than a specific period. The ACPI WDAT "Minimum Count" field, on the other hand, specifies the minimum timeout value that can be set. This corresponds to the min_timeout field in Linux's watchdog infrastructure. Setting min_hw_heartbeat_ms instead can cause pings to the hardware to be delayed when there is no reason for that, eventually leading to unexpected firing of the watchdog timer (and thus unexpected reboot). Since commit 6d72c7ac9fbe ("watchdog: wdat_wdt: Using the existing function to check parameter timeout"), min_timeout is being set too, but to the arbitrary value of 1 second, which doesn't make sense and allows setting timeout values lower that the ACPI WDAT "Minimum Count" field. I'm also changing max_hw_heartbeat_ms to max_timeout for symmetry, although the use of this one isn't fundamentally wrong, but there is also no reason to enable the software-driven ping mechanism for the wdat_wdt driver. Signed-off-by: Jean Delvare Fixes: 058dfc767008 ("ACPI / watchdog: Add support for WDAT hardware watchdog") Fixes: 6d72c7ac9fbe ("watchdog: wdat_wdt: Using the existing function to check parameter timeout") Reviewed-by: Mika Westerberg Reviewed-by: Guenter Roeck Cc: Wim Van Sebroeck Cc: Rafael J. Wysocki Cc: Liu Xinpeng --- Changes since v2: * Rebased on top of v5.19. Changes since v1: * Fix a stupid typo which broke the build. Mika, Guenter, I chose to preserve your respective Reviewed-by tags, as the end result is essentially similar to the previous iteration of the patch. Feel free to complain if you disagree. drivers/watchdog/wdat_wdt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- linux-5.19.orig/drivers/watchdog/wdat_wdt.c 2022-07-31 23:03:01.000000000 +0200 +++ linux-5.19/drivers/watchdog/wdat_wdt.c 2022-08-23 15:01:12.106398116 +0200 @@ -342,9 +342,8 @@ static int wdat_wdt_probe(struct platfor return -EINVAL; wdat->period = tbl->timer_period; - wdat->wdd.min_hw_heartbeat_ms = wdat->period * tbl->min_count; - wdat->wdd.max_hw_heartbeat_ms = wdat->period * tbl->max_count; - wdat->wdd.min_timeout = 1; + wdat->wdd.min_timeout = DIV_ROUND_UP(wdat->period * tbl->min_count, 1000); + wdat->wdd.max_timeout = wdat->period * tbl->max_count / 1000; wdat->stopped_in_sleep = tbl->flags & ACPI_WDAT_STOPPED; wdat->wdd.info = &wdat_wdt_info; wdat->wdd.ops = &wdat_wdt_ops; -- Jean Delvare SUSE L3 Support