Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1474039imn; Sun, 31 Jul 2022 08:21:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sTpyc3xZfYPLnCV8qKlsN8tP3Dj7Ev7lDB0/kAeb2XSdJ+Styhxy1bfB7qshW8KFNr9Bq2 X-Received: by 2002:a63:d70b:0:b0:415:f5f1:dd19 with SMTP id d11-20020a63d70b000000b00415f5f1dd19mr10002274pgg.273.1659280861727; Sun, 31 Jul 2022 08:21:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659280861; cv=none; d=google.com; s=arc-20160816; b=zTwhK89QOaXllNuDxVa5VKamIWsBQPeh5RvOxvM8mOHXN25MzDGeZp8vvOIrOhl5Mz ozLmvniYu4Kml6iLn4Efe48IRza24fFekdgxVlk+EireVvo0o5sqvjN2tm30VwRgupCD 9vFmlzKrNJzjgiP1jhvvItq6lUhqTDGX8vAQi56g0/sACTbSgrEMbzXNiF/NDqNU+FMd esumlDguT5ap32EgwZ40xXmvBVNKnrEs26wgjKp0fXBZvAQCaSHHgD95iQfJQN5m+45J VrehsFOtsDQHTXRimLC7lX3g2Ox0diroAlRXocKUb9TSTtiN2qJpGBIZcwOxpX6at+5u 0H3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Z/6G5EguNYfxzVz0kun3MQyyI0g17X6UECxjtk1iIN8=; b=PaVepWrStMc6TnOUcsjPuKqcSqJTHn8B2xPskXuqGiruulIMIR8rRRRx2e9cQp+XHv HF70DM+Pzu5RCCi/FO5sQCohAqalf1wCz97skcQjZxMp9Jt0p1CVtxZAlNMp0QHKVKTl Rv9DKX05e/H7C1tsgt9nH8/n+OoDjwlhxUQNbqgueVG4RGq/Vj9Jx2okEzc8IUUE+W9A d+C3Cxj9KF/xmRdzue5gj8WPU3YxMYyUB9iawcCRREztMmgfkQV1TOwkiDydq7HlvpIj j10/JflNX3cmRBZpRBiXAgphyd8akrDZ1m6xypwBHOLp8I8mTR+30Em7CtLSA9WEN0It ZzMQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a24-20020a1709027d9800b0016dd63c3d8bsi7245654plm.319.2022.07.31.08.20.47; Sun, 31 Jul 2022 08:21:01 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233746AbiGaORN (ORCPT + 99 others); Sun, 31 Jul 2022 10:17:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229639AbiGaORL (ORCPT ); Sun, 31 Jul 2022 10:17:11 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 91482DEC9 for ; Sun, 31 Jul 2022 07:17:09 -0700 (PDT) Received: (qmail 544533 invoked by uid 1000); 31 Jul 2022 10:17:08 -0400 Date: Sun, 31 Jul 2022 10:17:08 -0400 From: Alan Stern To: Guenter Roeck Cc: Alexey Klimov , 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 Subject: Re: [PATCH v5] watchdog: add driver for StreamLabs USB watchdog device Message-ID: References: <20220725030605.1808710-1-klimov.linux@gmail.com> <7770401d-fe3d-bda4-a2e2-55cd004a2d07@suse.com> <20220731082055.GA4008925@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220731082055.GA4008925@roeck-us.net> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS 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 On Sun, Jul 31, 2022 at 01:20:55AM -0700, 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. Are mutexes intended to be used in situations where one function acquires the lock, then returns, and then a different function releases the lock? I'm not sure about this. Perhaps a good old semaphore would be more appropriate. But it's clear that I/O to the device does need to be mutually exclusive with resets, one way or another. Alan Stern