From patchwork Mon Sep 25 07:20:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 144303 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1064102vqu; Mon, 25 Sep 2023 01:46:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGxvRgWKpBT+XcJliyUBFYz+vBeJda73u0NlDB4o+LlXWQUqzljSkyn8PIj25jWX2khNggW X-Received: by 2002:a05:6a00:1a8d:b0:691:320:b551 with SMTP id e13-20020a056a001a8d00b006910320b551mr7867341pfv.34.1695631578235; Mon, 25 Sep 2023 01:46:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695631578; cv=none; d=google.com; s=arc-20160816; b=Ea4vELZEXWap+JhuqgSlX+Hv/pUJBFNEvO/4CB60xzyvK6thmyTxpxWyCCg9vI37Wy k2QQ7WzNeJS9HWDvU/8ozzE0AgL4wyXrktw246mnOEEK7bhnd5VHXjd9VjV/nE0tVvJJ vRwUuZ/wUdZSVN8QK7xcMxveRBjGsOf8N5cRga7rwImOZJRU3Tw9QPB/ucWmiM4flh6K +XFqIyfRJyLqeDpi1r33UnHkXcrA2Fzusdl7uemIvvefC1fdXjmyJEf4faY6b9pCmwhW t8y43tVwnMMDAJi8DGQ3YCZmSqL9FGfnpCLhdSLhHDYDDGCBoswYPmhc5iAi+WwS2wyr Azww== 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:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id eb27-20020a056a004c9b00b00691019fd0efsi9781826pfb.75.2023.09.25.01.46.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 01:46:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; 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:4 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 howler.vger.email (Postfix) with ESMTP id 2C65E8091C57; Mon, 25 Sep 2023 00:20:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229865AbjIYHUU (ORCPT + 30 others); Mon, 25 Sep 2023 03:20:20 -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 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=0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Mon, 25 Sep 2023 00:20:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777998578010367116 X-GMAIL-MSGID: 1777998578010367116 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(-) --- base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d change-id: 20230924-ixp4xx-wdt-restart-d6bf28493173 Best regards, 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;