Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1749663imn; Sun, 31 Jul 2022 21:05:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR7IZmsOIovbCmBmxaMLbuj0324xIyKsy+V96MQmtp7fYzA0PpCZD8fVOu40Eb6XXME8dQYa X-Received: by 2002:a50:c312:0:b0:43d:962d:7db6 with SMTP id a18-20020a50c312000000b0043d962d7db6mr4397655edb.261.1659326754891; Sun, 31 Jul 2022 21:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659326754; cv=none; d=google.com; s=arc-20160816; b=O1xe7+ps5p3RppspL9YZC7ysaIkxxYe1vykN5X3ioxeKis/SFvuKi1+cCFjIjeWvFV GvtaClO+/+3jEkUHiqG6US6WfzTEbtx0NSRjb58+IZDMSk2ECj1gY2YnQcOd8oIqf/Vi l1tf3iICNGe9W+EF5zFARYwDFM6WpQb9Zns4DhuVWoXZx8OFmfZKZHIo5DEFDyx8qmNS O5lLuIfDYqXodOmWxQrhcEX58pexXm/CgIGYupoh24m6l9qWx/Y7jZtn6Lf+w/lsEyI9 FVpZCBzUJw4N7hKGDhcsM8qv5osbN1Ee1b06AAHM0R7r9hmi1Co6tXdyny71JcZfBz5M P6CA== 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=n9CkTzrmV50rz/zYav9x+RF/pPnwcqb7p6AKMW3GDVE=; b=mQXim0UoXGC83OUQIe2jXq0Dmmgrgivp8Pd9Yo9f6gFdKE0dBB0gayAaZrSf+J1zzc IWDaybJI743zMclRgxZEiGOFEOvzZSEA2XOgBzu+z7BipWr7A3SQSrPFZJOM4ePCABiI iYCOanMboSjGihLbYlhSkrTHwp18n4/K9S7GSFU0qWwuo8irgunfYd0TE/J6jDUkTyZI hKAVPR5RuYwvgSxZ+BOqax69LBubNbSbwiXPgXh4M9SJrqDR4wbSOtk63t2JC3zyxqHc mxIqV6B3bLtaRzk4kC9W7PsxSraryA3KwbLMqlZb6cAkMLHnQQViGR2/5fAsw/V6oni5 x8dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bYLg1gqy; 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 hw19-20020a170907a0d300b0072b1b099d55si6082480ejc.268.2022.07.31.21.05.21; Sun, 31 Jul 2022 21:05:54 -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=bYLg1gqy; 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 S233109AbiHAEAt (ORCPT + 99 others); Mon, 1 Aug 2022 00:00:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229497AbiHAEAp (ORCPT ); Mon, 1 Aug 2022 00:00:45 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF561B1F0; Sun, 31 Jul 2022 21:00:43 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id u3so12649495lfl.3; Sun, 31 Jul 2022 21:00:43 -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=n9CkTzrmV50rz/zYav9x+RF/pPnwcqb7p6AKMW3GDVE=; b=bYLg1gqyddQb/fdJtaz6CifAlxNtwd60RjS3APsY8uavHzjSp6HUjWINovZZBfbyqO vGZU4d3HuQDSF49FkDG9kXlS3DMv5dqV6sl86fT4MrFwPO1P6JYW2QyXt0NKWurueYqd FziDt1wWzmUAmCx+qE2hKM6th5NnKTNAl9Cn7QXkRMGVdn6ldEThi/opanrtq5yVXBPC +kBCSngHe1b4AxfYQtfZvLwC4mKAKwQHJwQ+JOwb4kBICPxpKCKJIBKey09tv64ovDcZ LkKD0XsTVtrA3CTcQeFPTZw45EarLdOpZzTACndcNOKk1ZI9X2oZfr9T8Sk/EnCThEVL GWhA== 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=n9CkTzrmV50rz/zYav9x+RF/pPnwcqb7p6AKMW3GDVE=; b=cBDQX7Y6UO8IfuFIGahIwnFgdoQN+NKgmVoklcDYn7pgHbJU86Epj9zfZQ7e+1hcbb v1/tscJ1H/ulEz/lDlGmfChNRnj3MExR4PgRRozxpaeRzcVDG1werxpqYzWazewUI9tz H/VKDbj7n0qTfeqTcsNHfkNRxXhHlaEfhGWR1UNTewVUzpYMOxk4LISC71PxlZNRydsj lQuZBwxO+MyrLUP1J4pxmiU1D/arWxvoS3C3bAp6KoOqIv60Q4owTAofSMJ2ZzOBiIyF 1g15Icl9PqGQXvWtJSnqSjyVDfUw/oaZC0wGmc2bEAqLSl43Ep8R2FnJ/6sUiCn3XSpt pvHQ== X-Gm-Message-State: ACgBeo0EH7Au5t76kdad3PmY2AdTuIsrpMrmVAH9Hz+KMathRzCBI2Mr XfxCxjsXzX384FbImeHwhl7Qe/0pHNrbW5FXikU= X-Received: by 2002:a05:6512:10c1:b0:48a:b8cb:ef2d with SMTP id k1-20020a05651210c100b0048ab8cbef2dmr4811968lfg.384.1659326442204; Sun, 31 Jul 2022 21:00:42 -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: From: Alexey Klimov Date: Mon, 1 Aug 2022 05:00:30 +0100 Message-ID: Subject: Re: [PATCH v5] watchdog: add driver for StreamLabs USB watchdog device To: Alan Stern Cc: Guenter Roeck , 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 Hi Alan, Thank you for your responses here and in another email thread. On Sun, Jul 31, 2022 at 3:17 PM Alan Stern wrote: > > 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. Thanks for the idea, I'll look into implementing this. Also, just to let you know there are a lot of drivers who do mutex lock in pre_reset and mutex release in post_reset. And there is 16-years old commit 47104b0dd32cec467574822b0dc3517b3de3f0ad Maybe usb skeleton driver could be updated as well. Best regards, Alexey