Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp504983rdb; Thu, 30 Nov 2023 10:13:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSvRM/Z8tMW3ZGfy1Rl5q8J8gEkoMGsvrpb5atEqffTtHh39PgQB/EQyG1/9LL0HuuQwrT X-Received: by 2002:a17:90b:8d1:b0:286:52d6:fa88 with SMTP id ds17-20020a17090b08d100b0028652d6fa88mr545824pjb.22.1701368023574; Thu, 30 Nov 2023 10:13:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701368023; cv=none; d=google.com; s=arc-20160816; b=GC+06YlTikE2MVsVpWBM9OfQvcl9z6YuSXz5SDOaTjC+Zeoxv4RfHW5bwf1822DrNy 3OR3Gy7EY5j7ONcir2erGukd0on4ToGVbEo9kztd+ShLS8oBYJoinbppZWDOL8D6jwYU c4Zqksog8zMyM2Prp/GgS4y7e4SOSHmx0eh7n/qfiSiTzXG5I4QKw257mZmhUT0rMBJV arBezn4WqD834DHkUMJZ+Gnzw41H/MtcKJUwtFpqAxfAN5BaZkbQ9eCWV94z+ETIFHw/ gyNC8Nd1/1Zl9Z4z2ZZ+ENnM8NPa5fdiLTzbeBmLeBAmA9otql6VLj2U6hKcegImk7xH ScBg== 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=wtZwCgOndtyg9G0GMwr+/ilwkHEDBsLXoDLM+zODq00=; fh=Fc5Ij1e3jH/iiqe4Wo51qjvJMz4Aprrs/JbFqX9MiYU=; b=Avfx1of6EohgTvT/6JkZcxlJkdKxQXSQf2dW+6maV5v7llEgXfHqEK0/4XMF2MY5qh AhWg1sQh30PbjItUDOu82/3Allh+cMAQyvNZVB8wYca8fv9UUns9JyyyGp9y+OzNGX7m 6oyPKv2uw6HXMinLAWdswf+YN3s1Cy/84UvZq91/4m8Rha2JOejMJ1KvG2Kpanu4HeiG 4FyqO/It+iGZ17NgPU07+nWBh6QfIY6g4YlGCWQ7PIplee74uS8vqVHLGmyYeJYgBABz 8lKiam+BJEcW4uE7Da2pRSPRhvssMIkVeoPNczLQ/z72riCA4Mx+RifEDYefWDDZS5/h WSZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id s30-20020a63215e000000b005a9debd7854si1659211pgm.828.2023.11.30.10.13.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 10:13:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 0F7FD802284D; Thu, 30 Nov 2023 10:13:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231330AbjK3SNZ (ORCPT + 99 others); Thu, 30 Nov 2023 13:13:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230045AbjK3SNX (ORCPT ); Thu, 30 Nov 2023 13:13:23 -0500 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 96B0DD5C for ; Thu, 30 Nov 2023 10:13:29 -0800 (PST) Received: (qmail 256744 invoked by uid 1000); 30 Nov 2023 13:13:28 -0500 Date: Thu, 30 Nov 2023 13:13:28 -0500 From: Alan Stern To: Jose Ignacio Tornos Martinez Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org, oneukum@suse.com, pabeni@redhat.com Subject: Re: [PATCH] net: usb: ax88179_178a: avoid failed operations when device is disconnected Message-ID: References: <20231130172525.193069-1-jtornosm@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231130172525.193069-1-jtornosm@redhat.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Thu, 30 Nov 2023 10:13:40 -0800 (PST) On Thu, Nov 30, 2023 at 06:25:21PM +0100, Jose Ignacio Tornos Martinez wrote: > Hi Alan, > > Thank you again for you comments. > > > What are these unnecessary operations? > Sorry if I was not clear, I was referring to the reading and writing > operations that are commanded within stop and unbind driver functions. > This operations are necessary if we unbind to get the device stopped in > a known state but if the device is detached, they are failing and imho > they are not necessary. That is the reason why I was trying to detect > when the device is really disconnected, to allow sending commands only > if the device was still connected. > > > In general, drivers should treat "unbind" the same as "disconnect" (in > > both cases, the ->disconnect() routine is called). If a driver tries to > > send commands to the device while the disconnect routine is running, it > > should expect that they might fail and not generate an error message if > > they do. > > > > (Also, note that the USB core will allow a driver to send commands to > > the device during unbind only if the .soft_unbind flag is set in the > > usb_driver structure.) > > > > And in any case, a driver should _never_ try to communicate with the > > device after the disconnect routine has returned. > Ok, understood, very helpful clarification. > In any case, I was referring to the internal operations during stop and > unbind. And if any failed operations are commanded before and after > disconnection (if any), try to detect with the warning to be sure if there > is any problem. > > I have checked that other drivers are using USB_STATE_NOTATTACHED to check > and confirm the device disconnection. And I am trying to analyze other > drivers to check if this can be done in another way. > If I use -ENODEV as Oliver suggested, I think I wouldn't know if the device > is disconnected previous to any operation. But maybe this is the way. I see. Your approach isn't all that bad. Another possibility would be to have the unbind routine set a flag in the private data structure, and then make the ax88179_write_cmd() and ax88179_read_cmd() routines avoid printing error messages if the flag is set. Or don't bother with the flag, and simply make the routines skip printing an error message if a transfer fails with error code -ENODEV. Alan Stern