Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1181203rwd; Wed, 31 May 2023 10:25:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5V7dteT+2OLDDPV3BUYk+RsH9R3vCink4223tA3Uc4uYO+uSTz8hacNqfsc4BMqJG8UB9J X-Received: by 2002:ac8:4e8d:0:b0:3f6:bffe:3c04 with SMTP id 13-20020ac84e8d000000b003f6bffe3c04mr6831221qtp.66.1685553958372; Wed, 31 May 2023 10:25:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685553958; cv=none; d=google.com; s=arc-20160816; b=e3kSj8ITmZDB3Gqn6EF2HnmBUTb7fnVYQ3YLDJwxgJ6TNtvcibYMEmnqHOWCWkH7JQ k9BY0tdpK67Ek3SQ5Llk/+Y/ohxIjXodpO5mQjH7oGhIcdb5JjoqzNQlDWvFuC0dw9W6 //IeGU+Ij//xFiV443RPiIp/O+Hu1VP/dmbbaIA1vR94QMgl/+nU87g/Kt5r2k+d/hLg CarpyS0yUYiHRHhyDqxayxwKSHIXoNfxb1aAAu1OLeuK1vz6pw3/qI5yARA9jOXiFS15 B4eS27iJsirRbCY9R4vgZskOpLZEt4cDkZBxdULy4YvNZITj8oJToz56IdNeYz05dz8P IhOQ== 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=DQdppZOPxZm8F1i/hMxCPwxtnw+E4aJrqvw5Y0ohZGA=; b=Ucj8+D6d9rlewgRaKEr8klCDHhUrz3jOhjJ1vGqkEQEkA790sjVCl/gGrsMZuRNJMm tH+l0Pm+vyrdvDWgyrnpfZ0zAX6PHONaTnI+nq8OB1oJ+PwPzh7IpM+4A6RaJsU7qDiu ojtVHQt26a1leWJM4011v6mZQELZd9muyrAx9WmPTeFnM1wqF/DuEG0LPoR4gYRrzyvj /San3kAG05/MntKRKuAWN2r98bnotwzKkcSbJtXK6OBV8gkNYJ5Qj97FMxnxtRdQsUmh lFyhr7pzGPSpdlUDaXASXv2NYSK/L5kceUvWpQ8YDmneiLkTgW7ZVCIAKMOmwPtqJqAo Z7ug== 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 x24-20020a63db58000000b0051394ccd19csi936045pgi.55.2023.05.31.10.25.44; Wed, 31 May 2023 10:25:58 -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 S230194AbjEaRK0 (ORCPT + 99 others); Wed, 31 May 2023 13:10:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230259AbjEaRKT (ORCPT ); Wed, 31 May 2023 13:10:19 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 8B951197 for ; Wed, 31 May 2023 10:10:16 -0700 (PDT) Received: (qmail 443922 invoked by uid 1000); 31 May 2023 13:10:15 -0400 Date: Wed, 31 May 2023 13:10:15 -0400 From: Alan Stern To: Roy Luo Cc: raychi@google.com, badhri@google.com, Greg Kroah-Hartman , Benjamin Tissoires , Michael Grzeschik , Bastien Nocera , Mathias Nyman , Matthias Kaehlcke , Flavio Suligoi , Douglas Anderson , Christophe JAILLET , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [RFC PATCH v2] usb: core: add sysfs entry for usb device state Message-ID: References: <20230531010134.1092942-1-royluo@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230531010134.1092942-1-royluo@google.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Wed, May 31, 2023 at 01:01:34AM +0000, Roy Luo wrote: > Expose usb device state to userland as the information is useful in > detecting non-compliant setups and diagnosing enumeration failures. > For example: > - End-to-end signal integrity issues: the device would fail port reset > repeatedly and thus be stuck in POWERED state. > - Charge-only cables (missing D+/D- lines): the device would never enter > POWERED state as the HC would not see any pullup. > > What's the status quo? > We do have error logs such as "Cannot enable. Maybe the USB cable is bad?" > to flag potential setup issues, but there's no good way to expose them to > userspace. > > Why add a sysfs entry in struct usb_port instead of struct usb_device? > The struct usb_device is not device_add() to the system until it's in > ADDRESS state hence we would miss the first two states. The struct > usb_port is a better place to keep the information because its life > cycle is longer than the struct usb_device that is attached to the port. > > Signed-off-by: Roy Luo > --- > Changes since v1: > * Address Greg Kroah-Hartman's comment: replace sysfs_notify with > sysfs_notify_dirent and remove the workqueue. > * Address Alan Stern's comment: replicate port_dev->child->state > in port_dev->state instead of using a pointer to link them. > --- Reviewed-by: Alan Stern