Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp5061430pxb; Tue, 5 Oct 2021 16:51:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTG5Va/a6vPIlsMQvwv3+PQK5ca5xGwW80nlw2XV8R8BYFeVER/ixjfbWWlP/6v1KjlwbH X-Received: by 2002:a17:90b:30cf:: with SMTP id hi15mr7017687pjb.5.1633477886305; Tue, 05 Oct 2021 16:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633477886; cv=none; d=google.com; s=arc-20160816; b=Uu8C2ZqOp8PMq6o2lVXX55ly3gLlA6QPbHR3PD/zKI90psZM/TQIvX8Q0F02SdF81m dB065w+YEMKonlILqme24Te7wnNdkEhVLHz4Mg/g4ZWn8fxKnZdtu/2gkeyOygvxhOce iXfT6umflccmsqf571TRjaloe/Wq1ds27dunm7SYdpGM3T59Qk4oSUWo9yrOb13ryIuy 5fdTIKDEa3ymVAlndGQ1DDHvHGibeTXKHO97QtwE4ymwLv1ULVci5Mtki8MuYSclA8wR 9qm3hnSNhYer6mYvG/T9ciaYh9UjWztqGc10kNEEOcgXcumdkubrY5dADbWCLlYRDi3M FKXQ== 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:reply-to :in-reply-to:references:mime-version:dkim-signature; bh=KVkB/xxIaRrACI2ADXm7FeOgUQdS3/51LOFgkKYmnLo=; b=KNll3eto2YGew2FCGP56mCATmu1xZawrpYww9R90QrO2WOgbPKQ6hf0k4jjJ1Q5+M2 EX70A5dSJGhWWHsBBw2qY4qFwhSYSVraBx9mQ+14JwVN2fhfiwaSoR21vRmTSIfjSBVi sgYZspxWMtlkyqUrpAW0AURTB/MqqZ+c6dqU6iszP13zKtpiewGWOK+cQvc28kDD6b7I QYZXP5LebayqReqbGE5PMIqCdRBnd1os0fWsjP2tJ4bd5PGZ7+i6bFlyCAQTbBKfgnN3 NdZgNbSrwCbotcFyISjCdaWqRPiSo69uFJRTwYWhaGXw4B/B4Jp+HfI7sL2tjeV66SBG Qlcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="jJ/TIjRJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si26516742pgw.185.2021.10.05.16.51.13; Tue, 05 Oct 2021 16:51:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="jJ/TIjRJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S236855AbhJEXvP (ORCPT + 99 others); Tue, 5 Oct 2021 19:51:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbhJEXvO (ORCPT ); Tue, 5 Oct 2021 19:51:14 -0400 Received: from mail-il1-x131.google.com (mail-il1-x131.google.com [IPv6:2607:f8b0:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 011A6C061749; Tue, 5 Oct 2021 16:49:23 -0700 (PDT) Received: by mail-il1-x131.google.com with SMTP id i11so39853ila.12; Tue, 05 Oct 2021 16:49:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=KVkB/xxIaRrACI2ADXm7FeOgUQdS3/51LOFgkKYmnLo=; b=jJ/TIjRJrqA9Z7zVbo6ragjrWVn6/UHnEyFha+dGVKd5Nq4xMOFd+DMNPejPCimWD5 ONuC1SmkKiAjs53YQZQ1fJHz2w7oaaC1oVZVVFLte58gx5mdC4chE81hLCl5GoCk4UuY T0ve7b5gQcDUmlTnQcf1J7aYhaGTOg3Nv0ZnfjkH0H4PbXHxLfVRGEtNbEqqVZDsDix0 CCX4hiUVJSkr9X0EoT6PiV3Rhoo1dqs+1Hpg8uZ2PdkmNTPy/CJ4dZ9ebCZRFbK/nxuw 40kg6JYfuoG7kJgC2IvV7lnCGucaxVn3IufUHmBU0cP9XpXh0rvFRElytUt8v4WGJYAD TgBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=KVkB/xxIaRrACI2ADXm7FeOgUQdS3/51LOFgkKYmnLo=; b=yefGxTux27z5FlYSSnAB9eO1/xMeYnu1zADWmIjRoMRe7CYQX9a4Ja2YbXZ6Fq7UeU pdQmAR2uGXwQqkgmO2cSho5mEYyYZOnr/nQ9q/bvLGta3nMngyNEtMi/keeD+MT5za14 FpvikhJnx5Mxqi8oecDqJp1vBPqu2Wdsa4EOutlXEe1wjZENlwZfH9nAOgGeDnjqzWLc H7PC2rT54deacyx94HFD0Fvo4vpKQ+OvoKou5DwT68mwgsNMKAPVEhhVPj1EXIDksime 36ynBS9WMQHXH2Z9nVctZm4WLZSrqmEH5dm2igy0r1XzXzSZWTMtWtqW+XUK/6YLGbVj n3mA== X-Gm-Message-State: AOAM533JHUiN8+0Ts14XfcqMBY4FDWmR6RYp3qUeTQcAizA/njazrWJK R7FDiMQb6OJI2pEbE25rFsM1NoFuChxY7OKyUdE= X-Received: by 2002:a92:ca46:: with SMTP id q6mr5257784ilo.59.1633477762353; Tue, 05 Oct 2021 16:49:22 -0700 (PDT) MIME-Version: 1.0 References: <20210929224823.556943-1-rajatja@google.com> In-Reply-To: Reply-To: rajatxjain@gmail.com From: Rajat Jain Date: Tue, 5 Oct 2021 16:49:11 -0700 Message-ID: Subject: Re: [PATCH 1/2] usb: hub: Mark root hubs on removable devices, as removable. To: Greg Kroah-Hartman Cc: Rajat Jain , Alan Stern , Thinh Nguyen , Mathias Nyman , Andrew Lunn , Chris Chiu , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, levinale@google.com, bleung@google.com, jsbarnes@google.com, pmalani@google.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 5, 2021 at 4:19 AM Greg Kroah-Hartman wrote: > > On Wed, Sep 29, 2021 at 03:48:22PM -0700, Rajat Jain wrote: > > Currently all usb root hubs are always marked as DEVICE_REMOVABLE_UNKNOWN > > unconditionally. Let us try to help the users to identify the removable > > root hubs, by checking the device on which the root hub sits. If the base > > (parent) device on which the root hub sits, is removable (e.g. on > > thunderbolt docks), then the roothub is also marked as removable. > > > > Signed-off-by: Rajat Jain > > --- > > drivers/usb/core/hub.c | 10 +++++++++- > > 1 file changed, 9 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > > index 86658a81d284..45d1c81b121d 100644 > > --- a/drivers/usb/core/hub.c > > +++ b/drivers/usb/core/hub.c > > @@ -2440,8 +2440,16 @@ static void set_usb_port_removable(struct usb_device *udev) > > > > dev_set_removable(&udev->dev, DEVICE_REMOVABLE_UNKNOWN); > > > > - if (!hdev) > > + if (!hdev) { > > + /* > > + * If the root hub sits on a removable device, mark the root hub > > + * removable as well. This helps with the USB root hubs sitting > > + * on the thunderbolt docks. > > + */ > > + if (udev->dev.parent && dev_is_removable(udev->dev.parent)) > > How can a roothub device not have a parent? It was a sanity check. I can remove that if we know that it can never happen. > > I still don't know about this. What userspace tool is going to do > anything with this information? What is broken today that this fixes? With these 2 patches, Chromeos intends to collect statistics about external USB device usage in the system. The tool will be an internal chrome os statistics collection tool. Today, any thunderbolt docks and its devices appear as "unknown". There is also a VM case that is helped by these patches, but I think Dmitry on Benson on this thread can elaborate more about that. Thanks & Best Regards, Rajat > > thanks, > > greg k-h