Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1738442imn; Sun, 31 Jul 2022 20:29:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1un52FQAwurMYeTE04FLSTcTZqPX9MELMXSv6MdoJQqCBQzM/NzI81OLAT++d74hoEjMC9m X-Received: by 2002:a17:907:8a1d:b0:72b:9e7b:802a with SMTP id sc29-20020a1709078a1d00b0072b9e7b802amr11286528ejc.189.1659324564812; Sun, 31 Jul 2022 20:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659324564; cv=none; d=google.com; s=arc-20160816; b=f8gn3Wm2p8SAkQYk1fiGqJ/zUyRJDe+ridxqYMfc5dyjLrZK8BXreEUHwO0j7XCed2 iekAWpfOoCab8KaSKmWYHqk5Up++KmesR3Bn1LUZxlwfbkPv6ufQuaEIv1jHzlRWOjc8 OCutD98bppeQhdVRf0++j65T+OELVXYehW7LPM2yNgfYYYiRkLgu8XpIL1cDWgGfNj4H E3NGdw1zM8v/dYvwFlW48zhYBP1nO6c2A/dkZA3gowHifCFHxppQEWpRaw/LlmLYDp3q CCUvG32VkJc4QNTBzOYOWcr7HWLdD2t7Jcv900TMzt+iLuPmWV39Mu/9pe+YLDypxslw Rt1g== 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=i8Jz3BTpeGtJm3GK1eZ2YEROBIkhtZGeBw2QJDaLLNA=; b=CyjoIXy5HiyDq/O2p11+dx35e4kpmt43nfSRQRz6dr1EjPhWbq+i7BCipDgAegcac+ bMoa3RoxxkbvWBDzK54/dMkSZ1+DyphEDyuTa6CaC+RzecV1R36uBsko2MBV3HfzrosD rJB8JLz03OOH6MlVPV8Ht7VmAmz5lmjy4X5RxuEWEg+bG+EJT6Ofj2POL1uMxqeHOZo+ RkUe9Rb5Eo5b3Ftt2EowcVPrN4q7kY1gLmnbeN4LhxmNOiwG2ytIH8cBQkeoVFQ+fqyb O5OAGZ86lkDjL4Qww1fmHijhYjqrTmnegbPh2Q8fCRGmUPAesri3uTASrGjGhAHpE1ka 00mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="enp33M/P"; 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 t18-20020a50d712000000b0043d6cfb83f8si3430998edi.418.2022.07.31.20.29.00; Sun, 31 Jul 2022 20:29:24 -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="enp33M/P"; 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 S238960AbiHADID (ORCPT + 99 others); Sun, 31 Jul 2022 23:08:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239530AbiHADHs (ORCPT ); Sun, 31 Jul 2022 23:07:48 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B10C140F7; Sun, 31 Jul 2022 20:06:54 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id h12so10886505ljg.7; Sun, 31 Jul 2022 20:06:54 -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=i8Jz3BTpeGtJm3GK1eZ2YEROBIkhtZGeBw2QJDaLLNA=; b=enp33M/PYqZZWP0JCm+W22PFu64pswsfAPsbjwZwGdhGBIiP4AdLhoVUVYHFKgPija AtVBscG379ZzIqvFl4cSz2Jkavm6q+6t9BJzKrgxcW0F+IKIrI2+EC7XGsk0Tel72t70 izUVT9m520ipG7gQhsf3+QerUHQNQldcYTiNgmI8DhrlBEXJrvhiYlKIuR67mPhGK48F J0j7SYexnJ5VUhrIONSGT18tF7R9q7i/qHwR4KQEQsMgpqhxwJFoljJX/t3/bBOWovjb tw0ypiWlp8gREGsDA9FQ5Nm+vNMWTMr7u1/BZnv7NsPhOwG9ACDDGl/3pyeGN+DUtML8 awrg== 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=i8Jz3BTpeGtJm3GK1eZ2YEROBIkhtZGeBw2QJDaLLNA=; b=FFq1Gt4U5ZjaS6lD4NU1j63LG3FaSGVjdnbaWkxskhn1j8b3PhCUdpGAuEAeMYVS7m lkXVlEWQHG1/rn/Z2lAnVF4xXclRNZA7MeD+SHGuJy9326Xrxul78Sdt5HIXZPU4Wue3 0y+65j4+PY4SrIRKQFg2ku1o/E1Shbu+tZG5kc/KRwrFTq0rPOKL9snh0Vf0H64GlTs8 Zmd9isRN+8GYWXVyj8+6KJGxqxb+yM0oay6FNu6W7xLGqxOfxh9wxO0VMSGh8BRDjMmt r4QN+8YMbyubS81drGyX/At8reQusyhfzhw6GOPn1AlfJqOgX5k0zlVMTFPSCEgmlUpZ 9n1A== X-Gm-Message-State: AJIora9/NM3/EhuI+p9pg8r3rTWvmn1IEYaMo32+KoGJQOpfOBLBYJ2b 6k8Ie7UGh8e0xR/CDpUGfrqqoM8xIFFLBRVAc5M= X-Received: by 2002:a05:651c:1250:b0:25e:954:97b8 with SMTP id h16-20020a05651c125000b0025e095497b8mr4470467ljh.215.1659323212444; Sun, 31 Jul 2022 20:06:52 -0700 (PDT) MIME-Version: 1.0 References: <20220725030605.1808710-1-klimov.linux@gmail.com> <7770401d-fe3d-bda4-a2e2-55cd004a2d07@suse.com> <20220731082055.GA4008925@roeck-us.net> In-Reply-To: <20220731082055.GA4008925@roeck-us.net> From: Alexey Klimov Date: Mon, 1 Aug 2022 04:06:41 +0100 Message-ID: Subject: Re: [PATCH v5] watchdog: add driver for StreamLabs USB watchdog device To: Guenter Roeck Cc: Oliver Neukum , Greg KH , 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 Sun, Jul 31, 2022 at 9:20 AM Guenter Roeck wrote: > > On Sun, Jul 31, 2022 at 03:34:16AM +0100, Alexey Klimov wrote: > > On Tue, Jul 26, 2022 at 8:48 AM Oliver Neukum wrote: > > > > > > On 26.07.22 02:21, Alexey Klimov wrote: > > > > On Mon, Jul 25, 2022 at 9:51 AM Greg KH wrote: > > > >> > > > >> On Mon, Jul 25, 2022 at 04:06:05AM +0100, Alexey Klimov wrote: > > > > > > > > [..] > > > > > > > >> Anyway, driver looks good to me, nice work! > > > >> > > > >> Reviewed-by: Greg Kroah-Hartman > > > > > > > > Thanks, Greg. If you don't mind I'll use your tag in next version > > > > after making changes suggested by Guenter since there will be no > > > > significant functional changes. If code will change a lot, then the > > > > process (Documentation/process/submitting-patches.rst) will require me > > > > to drop the tag. > > > > > > Hi, > > > > > > while thinking about this a question arose. How does this > > > device react to a USB reset? A watchdog that can be disabled > > > by a simple reset does not like very reliable to me. > > > Do you need to implement pre/post_reset() ? > > > > You're right. Upon reset the watchdog is disabled even if it was active before. > > Adding empty ->pre_reset() and ->post_reset() helps to avoid that, but > > looking at Documentation and other drivers it seems that I need to do: > > in pre_reset(): > > mutex_lock() to block any other I/O to the usb device; > > __usb_streamlabs_wdt_cmd(STOP) to stop the watchdog; > > and do not unlock the mutex; > > > > in post_reset(): > > if (watchdog_active()) > > __usb_streamlabs_wdt_cmd(START); > > mutex_unlock() to allow other's I/O to the usb deivce. > > > > Seems right? > > > Not necessarily. Is other code doing something similar ? > Using a mutex like this creates the risk for hung tasks. If other code means drivers in tree, then yes. Examples are drivers/usb/storage/usb.c, usbtmc.c, synaptics_usb.c, vub300.c, zd_usb.c, usb-skeleton.c, etc. I'll check the Alan's suggestion and will try to implement that. Best regards, Alexey