Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp506095rdb; Thu, 30 Nov 2023 10:15:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSRcgZNxIiLK0ieKuUMCs42yqfxLZK/dBoijLz0L/vDdBjXjdtJc3QhEcvnbhy1omjFPMd X-Received: by 2002:a17:90b:1a89:b0:285:93ef:115d with SMTP id ng9-20020a17090b1a8900b0028593ef115dmr31662472pjb.4.1701368127218; Thu, 30 Nov 2023 10:15:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701368127; cv=none; d=google.com; s=arc-20160816; b=SZ/RCvSad6lbqVBw0+pzXjfDNNDEwkn+B1QhY3p5batu7JchtavasK5A4R9DjGcYid eTmqlB6D9J3KWz9wwOV/VfvUwaDMSYdNbfkwqukzHDsGCRIEEVND0k7J8J45uaZUjBF0 F4SHWgtiun3/wXwjsXdtQyTNfVftg5O+YV9qklM4x/XppybWCXHy/Qd73wDT1skghyKx 3YUYq7cgvdgdLgqk+uSdXgBIzHbaMEAX9ZRbEVkvJyf95fH9MZyR1EfAMNpifowxeGSf HCI5heR3RGjqt76vW9T9eNJ0njtOmFM6dwKczhCPRlGxMW+67wZDCeb/kpOvGZ0bqEgN xbQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=z3+asrSFrGo9UuOPMpB+FykgEmlyfPD8k1SOx9pGWoI=; fh=hJ08VrQ01skH5nJ/kAqAP8O+i8T0nrBnCP4uQOE6o5U=; b=mHINb7jH7FyIHQUi3Ymu1uHdm81voWFmR+OBkvc2elJGoazacjaef0fzgEGXSLtgOJ 9oAWNwNxkxcFHuIazu0kTbK8Q5yUTSAS3rX8nOmaRgEk+1tiTVX9n8wVhh1sp6z2wX5t psYCpqL6W8mwgKHdo/CESN3xTB36JfOfNRyZjm4SUCZMnz4DEuGUTq9uafWfzNFtq0WB 0A+JjvNu/x++DCS8ldWguI6IcsjW+/ir4ixqbl/1ejGo0qwU2msE7aOd9j6jFbe8e+eY UJygp0yvmKPpdSorkA8GtWjMMwn+tOYIGa4XeGDTxeia3IF0qVz/NG6kGiEHLI8eWUAG Fi+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=V7H8vn9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id a7-20020a17090a854700b0027e022bd420si4156575pjw.77.2023.11.30.10.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 10:15:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=V7H8vn9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 09610802284D; Thu, 30 Nov 2023 10:15:06 -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 S230106AbjK3SOs (ORCPT + 99 others); Thu, 30 Nov 2023 13:14:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346437AbjK3RZk (ORCPT ); Thu, 30 Nov 2023 12:25:40 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B63E51704 for ; Thu, 30 Nov 2023 09:25:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701365135; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z3+asrSFrGo9UuOPMpB+FykgEmlyfPD8k1SOx9pGWoI=; b=V7H8vn9JGVuJDTkyHtXvQpR1NNUXpT4GshbXpqqPASNL3+PgSD4psQTPyuFIYgZmpY9tKt LqWbEtYwibQaFDihQyjiGshUU8860/lLUoXgQMC1C58/HUWNFt0Nze3wP2NagxAhwKT4lA WefqQn1+vI3WSDf4KT4obzj8zk3zVrw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-60-hZEARIXePO-JRq5KGeOjXA-1; Thu, 30 Nov 2023 12:25:29 -0500 X-MC-Unique: hZEARIXePO-JRq5KGeOjXA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 31FE8101A53B; Thu, 30 Nov 2023 17:25:29 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.39.192.105]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD270492BFC; Thu, 30 Nov 2023 17:25:26 +0000 (UTC) From: Jose Ignacio Tornos Martinez To: stern@rowland.harvard.edu Cc: davem@davemloft.net, edumazet@google.com, jtornosm@redhat.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 Date: Thu, 30 Nov 2023 18:25:21 +0100 Message-ID: <20231130172525.193069-1-jtornosm@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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:15:07 -0800 (PST) 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. Best regards José Ignacio