Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1738088imn; Sun, 31 Jul 2022 20:28:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR5xuMMJu4GqbuNr6m5Ks5SabfQXVrW/l+3F/KAsT8uOij0oOGAgF/HrwHH+QZVk9wfQL0SJ X-Received: by 2002:a17:902:e84e:b0:16c:773:9daf with SMTP id t14-20020a170902e84e00b0016c07739dafmr14837733plg.43.1659324495042; Sun, 31 Jul 2022 20:28:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659324495; cv=none; d=google.com; s=arc-20160816; b=jzr0Idxxvo+ntobZv/SePKMRXhN7q+T7YSPc7QGy5tvotm8Jk5fNvNBi1DakYn31au 8w6ZoXPfk7gXPfYUonGHa4kbxBHPakWDHVB8QUD+zu+V9B2/KfqgobO82ytntIaUfRF3 HQ6vFNzUAeTiAp3O0AOPQzolzfKNMzhnUeBW4OCYd4suJtOnSTLPCcsiPXwN8ebpOupf H9aUzQjvy62ivvMEWoDE7KUkoXnFfYHY3WQmb/V6hPAgMm00e5y7fDr0TdirhLSLsw4n bmsrXRGK7HH+D71KljuJcsQ8/iejlWy2HfzSA6ZfeIEuB8nLqUyT1vZ4EjnaSn8dM/8X 9oWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=4PUW35Z98Oz3GKgcOUm+Y7kv0FX17sX3vwCDCp2HW74=; b=jGUoFY8vGKzrp33S9zs/3txcF1M7V8hZUw2qI1gL2YLTGXrPczpi8I267aeHxHfTcE TVljlJR9IcUO5xcevtmXV1/Gfdn7GLeG4TRKAf6OFN0vA7aTb0MrUN5CespqN7syxjYX 9r0FvUWzyaz7YpM+Z+neWXH4QkcxusvU+dRgZTqgRim8mPFqxqdZVgjcJRFxxU2H2XOQ /qu4gxoRQY1KK9lHbwO2DLf+7VwQPXHS73YbQ/zMwPeY9+QAYW7462rlwOqs938SPNn6 ZeoaZd58QhLQ/DECGBFrkQyzShSgf/WKsZtIVyw1gZ7yLhX3rLRJhQXt13KxIZGCFPef jhcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XiXlx6p8; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t62-20020a638141000000b0041b8f2bd530si3789546pgd.217.2022.07.31.20.28.00; Sun, 31 Jul 2022 20:28:15 -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=@gmail.com header.s=20210112 header.b=XiXlx6p8; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239442AbiHAC6n (ORCPT + 99 others); Sun, 31 Jul 2022 22:58:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238241AbiHAC6m (ORCPT ); Sun, 31 Jul 2022 22:58:42 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 964FCDEFC; Sun, 31 Jul 2022 19:58:41 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id bq11so10184777lfb.5; Sun, 31 Jul 2022 19:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=4PUW35Z98Oz3GKgcOUm+Y7kv0FX17sX3vwCDCp2HW74=; b=XiXlx6p8Um99lzIHizjEqBOBY3WY5XMxC2b6+HjzF4cozzUWdTyzmK2AHSD6K6S+7I 0047Tv6qHYK2KCJ1a8ke1ALewQ/Rv/scuGG4b4gxCzzdKjx8MP3akB0coQg/gerxqmzU OSC8e5CEbR1NxTUNFFhmKvnxBoG+kMBpZwDapX0Jr6TGriN5GGRa2p7ShQcL+8EPjrOx LmJNQDmFQ8iomSKarCsys/XZqZOXUwRvXxfeLISBVZrmLNi1bzS5iDOyzAlAOu7gZtPE 1oJTkThe0sWsLoUA1fjeCt4d9C0eR5gtfQuLAMl7SlkvnSBV+gvnPeXlFjqKm9PGwT3R VKYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=4PUW35Z98Oz3GKgcOUm+Y7kv0FX17sX3vwCDCp2HW74=; b=6ipEtFxtHLjsuLasq4wGqIRPVTFoHTc54yr7vcuQbrybzs7xlVexcOuW1KdNv4/iuj 9RR4RK8mLT3DrO/0V0kloEvHLjDzpveJqH66WQALvOqL4o2oVgYW6EWfDomZXaH7TaJs GIb+mLKMFl2/Ddl/jZ28KTHLEg+yTbllEANH2Ae8hJKat5TSpYt16Ot5RogrB3/xUrOW quh96BA0KroI7t9LgDpJZ35rkyoWTHa+zl8Zgte17r94dNm8yNHqXxdLrkDBqoMuADk3 iR0pScgKCSKvn1JKO6Dt0/jcyj10MExe8kZf4bjM0d29LLGafuvYgOOfotuW/aLykjGd 7CZQ== X-Gm-Message-State: AJIora9/E9KPUkYIAfMB25wlF9qxK7qGEppI6T/XLZDtw/huuwB9GGBC 20xp52OcwKa0xFzNuR7WI7bGtwlCvwpURBJkdrk= X-Received: by 2002:a05:6512:1319:b0:482:b8ce:a278 with SMTP id x25-20020a056512131900b00482b8cea278mr5121005lfu.8.1659322719820; Sun, 31 Jul 2022 19:58:39 -0700 (PDT) MIME-Version: 1.0 References: <20220725030605.1808710-1-klimov.linux@gmail.com> <573466e4-e836-d053-d1b9-dc04c6a046e5@roeck-us.net> <20220726032425.GA1331080@roeck-us.net> In-Reply-To: <20220726032425.GA1331080@roeck-us.net> From: Alexey Klimov Date: Mon, 1 Aug 2022 03:58:28 +0100 Message-ID: Subject: Re: [PATCH v5] watchdog: add driver for StreamLabs USB watchdog device To: Guenter Roeck Cc: Oliver Neukum , linux-watchdog@vger.kernel.org, wim@linux-watchdog.org, USB list , Linux Kernel Mailing List , atishp@rivosinc.com, atishp@atishpatra.org, Yury Norov , Alexey Klimov , Aaron Tomlin Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On Tue, Jul 26, 2022 at 4:24 AM Guenter Roeck wrote: > [...] > > > > + > > > > + streamlabs_wdt->intf = intf; > > > > + usb_set_intfdata(intf, &streamlabs_wdt->wdt_dev); > > > > + watchdog_set_drvdata(&streamlabs_wdt->wdt_dev, streamlabs_wdt); > > > > + watchdog_set_nowayout(&streamlabs_wdt->wdt_dev, nowayout); > > > > + > > > > + retval = usb_streamlabs_wdt_stop(&streamlabs_wdt->wdt_dev); > > > > + if (retval) > > > > + return -ENODEV; > > > > + > > > > > > A comment explaining why the watchdog is explicitly stopped when running > > > might be useful. > > > > What do you mean by saying "when running"? > > Everytime during my testing the initial state is "stopped" on > > boot/power on/after reset, so not sure what you mean by saying "when > > running". > > Should I have used the term "active" ? "started" ? > > > There is a comment above that explains the stop command but I will > > add/change comments that explain things better. > > The point of executing "stop" command here is to check that device > > being probed behaves like we expect it to. This is a bit paranoid > > check since I am a not 100% sure that all devices with such USB ids > > are watchdogs -- that's why additional checks for usbdev->product and > > usbdev->manufacturer and this stop command that doesn't change the > > initial state. In theory, I can remove this stop command at all. > > > > Normally one does not want a watchdog to stop if it is running (started ? > active ? pick your term) when the device is instantiated to avoid gaps > in watchdog coverage. The watchdog core provides a flag, WDOG_HW_RUNNING, > for this purpose (sorry, there is the 'running' term again). It is used > by many drivers, and ensures that the time from loading the Linux kernel > to opening the watchdog device is protected by the watchdog. > > Calling the stop function during probe suggests that you at least > considered the possibility that the watchdog may be running/started/active. > Per your explanation, you still want it to stop explicitly if/when that > happens. All I am asking you is to add a comment explaining why this is > not needed/wanted/relevant/supported for this driver. One explanation > might, for example, be that the state can not be detected reliably. Thanks for the explanation. I was confused initially by the phrase "explicitly stopped when running" since in reality it is "explicitly stopped when stopped" (or not active, not running). On the second thought, I can issue a start command and indicate to the watchdog core via set_bit(WDOG_HW_RUNNING, &wdd->status) that it is running or return -ENODEV if the start fails instead of stopping the watchdog. I just would like to have a command sent to the device in ->probe() that checks that the device behaves like expected. If there are no objects I'll change it like this. Best regards, Alexey