Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1110953rdh; Mon, 25 Sep 2023 03:46:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPpEKvKG6eHSkIBXmdCWPWIxi/8Kf9bZbjkoEB6DVkY4uMK1sqLUxSaPqcB/oe2xIhcWL3 X-Received: by 2002:a05:6a00:c86:b0:682:537f:2cb8 with SMTP id a6-20020a056a000c8600b00682537f2cb8mr7996609pfv.26.1695638770151; Mon, 25 Sep 2023 03:46:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695638770; cv=none; d=google.com; s=arc-20160816; b=Oac7V9rLS/z4JUB8VsNxuFyUbKa6cLOo372TP9TQ6efrk32HfBWF0oshUJFU2LlwTF FhTYzcnrly4OjzR2d/325RJbhmtLLefdrB0Z9cowYnaX9UtjoNZVZqD9sFqWBm8I96Q7 t2iKO9mhfI1CdBMNe321OhzNu9gIfskl1Wl1f8adWVfiuTsIH3ISFDgsCP5PpeMLzeye Md/b8ucPpADKPtiW2iJcVEAvrFlMmVBE3Qi7w8l2bEtOm4ZzNxiyOVYt63fGfphXKbg1 xNocSA3NubiLKfs8JcmfCzHWE1M9N3LNpO0+Y7TYWDLP1fekwXVykafG44m2jhc6Tg// 0oWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=bxM9GVR4VSyyuE43awaZA1Wf9nkVTXawgZ7CU1WHNlk=; fh=oFDhbFRE8uJiZ0yD6extGNiHeYxHps0FwEh7iYsxUY4=; b=MDG9CwCVO0K5mMpaBo8kZKtj8jscOZZRjD8XlRIYZwNGYyz+J/R6ms80dKVlvqS3ng gwT7g9TIu210lmuu3BBDYomE8U7nsHH5oMrcwYzMvA4ScHT5uQ0flVBbAQ3mUO9qUj6E 43oUS3+eyTvssaZ+YmAymEaq5XlwBF3K2TF4AboqT/qAzqRame33KPD27KLUmzidAPHT jWG1wks2KZ6ldwGGxb4GWmLb4PaBif0aiffiiUljcc1+mvluhNQurNbHnLY1bczjbNc8 eRkFlbjy368Yhy1newSa68np81SZeSl9EbbMCZe+JlgoTJrY9XEAigKUIzJtC5Nsod3N IC1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QHfa9thX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id h132-20020a636c8a000000b00564bcae8b53si9539869pgc.803.2023.09.25.03.46.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 03:46:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QHfa9thX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id E54BA8092480; Mon, 25 Sep 2023 00:20:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229459AbjIYHUT (ORCPT + 99 others); Mon, 25 Sep 2023 03:20:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbjIYHUR (ORCPT ); Mon, 25 Sep 2023 03:20:17 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0EF3106 for ; Mon, 25 Sep 2023 00:20:07 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-5043a01ee20so6837930e87.0 for ; Mon, 25 Sep 2023 00:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695626406; x=1696231206; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=bxM9GVR4VSyyuE43awaZA1Wf9nkVTXawgZ7CU1WHNlk=; b=QHfa9thXAP8hbolUZ3uR7e+tTwQEAdB3+Ym8szSQSFnWqNyxNdIVEydIYtqslqTjmZ 97+NyqIIVufa5W3hTkTJ/r/JqCnSHqEVSsvHC0UecsVVknupUG6YkZFCKLlt82C4Jsy6 SWIfzuuVsinAxXydqfYwR+RSphaZQ5JXTFyyECYCM1Kkqs2+92xLcrJmyiTdbovBQ9+g /yipWL1c0wbM27DlOE3HgajaSjMbHbrLB2n/2Zs9qC795Q9jCpF7okOhIByWAu1KF3Vd sdGyhsqoIxm/AOB08hFSvZlBU4WkrUwZOdKkJQZlzJe2pdK96gxVhLSAIYHEXbpIq8KL NIcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695626406; x=1696231206; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bxM9GVR4VSyyuE43awaZA1Wf9nkVTXawgZ7CU1WHNlk=; b=GwD3ddsRrb6uG1/M3+G13eKQ9mlyItZ5RClIqAAWWg1xwK0V6WrFiiSjVfo/+mkDQ3 TSkz7kiwwjZNepyCd+10kfUcz0Is8tW3DBsjcxgTJds+Bp5p8XMlI33+Rwv4Q31+BfrJ GqOB4zTTOY7CjoYmX2IpP6522SmdGcXwDn1era0gIqIBP5BOO288ZEa0N1VzyAgb/zbd n049npGalzFtVa2DZTgH8xFLE3CF1S1R9AhBPA+woTDHcHMBk9Pw2Q/Q81iLlqGNGHiC 8ZxjujUCp/HW7bBBl3lSUtwLOFhAedCSE6QWNnDGdEA1+zhdqHl+EqG7O/E/brOe4f1L /Ojg== X-Gm-Message-State: AOJu0YxhFbzszZyY7y5H0qc3j6UEZUmA731eKSPah2i9lTzDbkfEfqVr kP9mQHfQr8pDJI6fMV1j/MpLhF1D1XUAvkMXHIQ= X-Received: by 2002:a05:6512:2812:b0:503:1913:ed8e with SMTP id cf18-20020a056512281200b005031913ed8emr5445725lfb.61.1695626405907; Mon, 25 Sep 2023 00:20:05 -0700 (PDT) Received: from [192.168.1.2] (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id b11-20020ac2562b000000b0050096cc3ba1sm1722178lff.255.2023.09.25.00.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 00:20:05 -0700 (PDT) From: Linus Walleij Date: Mon, 25 Sep 2023 09:20:05 +0200 Subject: [PATCH] watchdog: ixp4xx: Make sure restart always works MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230925-ixp4xx-wdt-restart-v1-1-fe2b9b131dbf@linaro.org> X-B4-Tracking: v=1; b=H4sIAKQ0EWUC/x3MPQqAMAxA4atIZgPaFv+uIg5qU82ikhYtSO9uc fyG917wJEwehuIFoZs9n0dGXRaw7vOxEbLNBlUpXfXKIMfLxIiPDSjkwywBbbM41Zle162GHF5 CjuM/HaeUPpERByZkAAAA To: Wim Van Sebroeck , Guenter Roeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 X-Spam-Status: No, score=1.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,SUSPICIOUS_RECIPS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 25 Sep 2023 00:20:25 -0700 (PDT) X-Spam-Level: * The IXP4xx watchdog in early "A0" silicon is unreliable and cannot be registered, however for some systems such as the USRobotics USR8200 the watchdog is the only restart option, so implement a "dummy" watchdog that can only support restart in this case. Fixes: 1aea522809e6 ("watchdog: ixp4xx: Implement restart") Signed-off-by: Linus Walleij --- Other solutions like implementing a pure restart notifier callback catch in the driver is possible, but this method will minimize the amount of code and reuse infrastructure in the core. --- drivers/watchdog/ixp4xx_wdt.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/ixp4xx_wdt.c b/drivers/watchdog/ixp4xx_wdt.c index 607ce4b8df57..c0bf03125ec8 100644 --- a/drivers/watchdog/ixp4xx_wdt.c +++ b/drivers/watchdog/ixp4xx_wdt.c @@ -105,6 +105,25 @@ static const struct watchdog_ops ixp4xx_wdt_ops = { .owner = THIS_MODULE, }; +/* + * The A0 version of the IXP422 had a bug in the watchdog making + * is useless, but we still need to use it to restart the system + * as it is the only way, so in this special case we register a + * "dummy" watchdog that doesn't really work, but will support + * the restart operation. + */ +static int ixp4xx_wdt_dummy(struct watchdog_device *wdd) +{ + return 0; +} + +static const struct watchdog_ops ixp4xx_wdt_restart_only_ops = { + .start = ixp4xx_wdt_dummy, + .stop = ixp4xx_wdt_dummy, + .restart = ixp4xx_wdt_restart, + .owner = THIS_MODULE, +}; + static const struct watchdog_info ixp4xx_wdt_info = { .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE @@ -114,14 +133,17 @@ static const struct watchdog_info ixp4xx_wdt_info = { static int ixp4xx_wdt_probe(struct platform_device *pdev) { + static const struct watchdog_ops *iwdt_ops; struct device *dev = &pdev->dev; struct ixp4xx_wdt *iwdt; struct clk *clk; int ret; if (!(read_cpuid_id() & 0xf) && !cpu_is_ixp46x()) { - dev_err(dev, "Rev. A0 IXP42x CPU detected - watchdog disabled\n"); - return -ENODEV; + dev_err(dev, "Rev. A0 IXP42x CPU detected - only restart supported\n"); + iwdt_ops = &ixp4xx_wdt_restart_only_ops; + } else { + iwdt_ops = &ixp4xx_wdt_ops; } iwdt = devm_kzalloc(dev, sizeof(*iwdt), GFP_KERNEL); @@ -141,7 +163,7 @@ static int ixp4xx_wdt_probe(struct platform_device *pdev) iwdt->rate = IXP4XX_TIMER_FREQ; iwdt->wdd.info = &ixp4xx_wdt_info; - iwdt->wdd.ops = &ixp4xx_wdt_ops; + iwdt->wdd.ops = iwdt_ops; iwdt->wdd.min_timeout = 1; iwdt->wdd.max_timeout = U32_MAX / iwdt->rate; iwdt->wdd.parent = dev; --- base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d change-id: 20230924-ixp4xx-wdt-restart-d6bf28493173 Best regards, -- Linus Walleij