From patchwork Wed Sep 29 22:48:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 12526895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C357CC433F5 for ; Wed, 29 Sep 2021 22:48:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A8B361439 for ; Wed, 29 Sep 2021 22:48:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347333AbhI2WuN (ORCPT ); Wed, 29 Sep 2021 18:50:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347236AbhI2WuJ (ORCPT ); Wed, 29 Sep 2021 18:50:09 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AA71C06161C for ; Wed, 29 Sep 2021 15:48:28 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id az37-20020a05620a172500b0045e43348ee8so11256620qkb.19 for ; Wed, 29 Sep 2021 15:48:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=ETcVWno/psejFFgEWsam5NI1lLczvhwOhyjFPnZZicY=; b=EghzBSYgJaumTGBJNjWIlqQkmELd14y20ZMqLBeHV1G43vyoHX7wZUtHS9Ck3OyXke SJxanL4NUMcG2yOWC0yktYmJtOqYlceftM6+fKTjzlp5v0RL0Vebi0WwQ4Pcr8M1FNBu ePRwE2Vy1dyMsGEFKDxhVwcXK5wlQGyY/RpekflN21IJzxBkhoUUyhj7ODMQL5SNi4yF dwNFomcEZiFu35kZnbSH8XNl0ihfsZere/O79Xbn2MF+7Hc4hXdf5+q+TkQuxfsc1wvn nyAObw/ixyyJgz3hPODjhD1k6kMPbQKYWt/emXaDstFNHpvJkMRTNk8RRjC3rnCUn31S tJ0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=ETcVWno/psejFFgEWsam5NI1lLczvhwOhyjFPnZZicY=; b=qsFrVvUgdJH1uSUpg34+APHJ6pc4FedjV5MEp4L8KMGHEhwRlm/F4YzqqSHUJVWdcH 5L/4CHreHSXVoYdrWFsEoVz1ZeDwlX2798UxSFp7h+lF9frL3q2+NO0ADfrw7IrirazM ZLY9qi+E9NxN40aP09z8CyXVJAo3b/jmS6adpoOVnmdN+1bUuuS6YQ7F9sARCGl1qjSe WxhNjYh7BKlx9od1a5MwZZrVixDC1I37ENcLrcjh43ABY0vbLTypxX+qvv/Zm74ReywK ZwjK6mFnMQhkZijE3gufEqpXNSGW531Xn5VA+XN/V6U7nv0Yjl82T7waBQ0W4zEkpcZS CAeQ== X-Gm-Message-State: AOAM5327VEieCUwJ3D1N0ZdAyfllOkNvnAcT1NMHgqepIjwRUKlCO7bg NqhmY5JK2mQNbsbXO9rzhz5CFLOrb6yN X-Google-Smtp-Source: ABdhPJz4dFZxZ37NcH6OGB5NWytbGQwJt62+4qAU4i+rz/Y1LnFor5rxegWAq8JofebiYEc/pO27ztkLBYHa X-Received: from rajat2.mtv.corp.google.com ([2620:15c:202:201:d512:b04f:25a7:c7f]) (user=rajatja job=sendgmr) by 2002:a05:6214:140c:: with SMTP id n12mr2370973qvx.39.1632955707380; Wed, 29 Sep 2021 15:48:27 -0700 (PDT) Date: Wed, 29 Sep 2021 15:48:22 -0700 Message-Id: <20210929224823.556943-1-rajatja@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog Subject: [PATCH 1/2] usb: hub: Mark root hubs on removable devices, as removable. From: Rajat Jain To: Greg Kroah-Hartman , Alan Stern , Rajat Jain , Thinh Nguyen , Mathias Nyman , Andrew Lunn , Chris Chiu , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: levinale@google.com, bleung@google.com, rajatxjain@gmail.com, jsbarnes@google.com, pmalani@google.com Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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)) + dev_set_removable(&udev->dev, DEVICE_REMOVABLE); return; + } hub = usb_hub_to_struct_hub(udev->parent); From patchwork Wed Sep 29 22:48:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 12526897 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5B05C433EF for ; Wed, 29 Sep 2021 22:48:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBED86142A for ; Wed, 29 Sep 2021 22:48:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347344AbhI2WuP (ORCPT ); Wed, 29 Sep 2021 18:50:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347331AbhI2WuO (ORCPT ); Wed, 29 Sep 2021 18:50:14 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FCF0C061767 for ; Wed, 29 Sep 2021 15:48:32 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id r5-20020a05620a298500b0045dac5fb940so11342235qkp.17 for ; Wed, 29 Sep 2021 15:48:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=mFpUuvuBysqSnfHqvwDvzANzBcF7cW/0AhHxyq0yb1s=; b=Xxllz9r3zQ7FdUefiuUS5kevHpMWap6f7+0JlD4MKmf0vYLOLs8VBSHFqjD4OumEaD RDYBm8Jy09Ot4eBxC8XZ2evmtT/TUnNRfKWWxgfbvvLLLw6Y5CdRYIuHAtiPSSdz2ypp 0mX8FBiJoz3+zzwvyoM+OW99mqENXsgT/YZh52LKZXPENBF9oG9Lm4/KzRj8hq168pB3 J3LxLTZoccMlTP5bkJeYeD83tJO0+3RfRMCVT5TAK2ItacCStU4+4Xu3gp1SEjR9W4/3 ihxpjvO21LGKWM8m4B0VRNh7L20IHZw43CTz8IT/i5EGqFETOjFrNxTv0BSNuoLAFSVO tLjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=mFpUuvuBysqSnfHqvwDvzANzBcF7cW/0AhHxyq0yb1s=; b=pg/4EhQrpxB8ByCMMjsuv7WyMWi71wlTsMMvPXaN/WXDiC0mDh/WaNYWSOpIqZlF0/ 2U0LwB4uUbJrodjpyBgzMt7H2/62qfS0ADd/8tTakNmoj0MzptqUrKXdFVrW53JRJAwB ITe1hxx6jlg2+IInGvvYW0YjlraMEv8GC+zWgi8c6FjLDeGfTKomegFuVU2b0ni4buK9 cPPrQ6HtmhUgLR0P4aiQsXKnrupR5Mvz6eN84FUj/H5CpyJdThxYi9dQdLJgX21XNDmQ 8b7ruXIuPS493kUM86DYQgnTZo0rQ0wBh9WtpFyuapAGohyrg8XaueDVjfQ8jWab99CR YQsg== X-Gm-Message-State: AOAM533nk+tg4MtN2nAy8kCwSPq+CZEnK685ML4DVw1XIJlQaCNBusPb c6u2vlXwjlyoTNJ/frLbZa9y780CB6Og X-Google-Smtp-Source: ABdhPJygHQnglVl5yNrmZd8JNAstsl85b+1dCuzHHaOIhfPNgsUwoZudN05/VWdUigVG1DEnAP/66jrp3aib X-Received: from rajat2.mtv.corp.google.com ([2620:15c:202:201:d512:b04f:25a7:c7f]) (user=rajatja job=sendgmr) by 2002:a05:6214:122e:: with SMTP id p14mr2344816qvv.37.1632955711698; Wed, 29 Sep 2021 15:48:31 -0700 (PDT) Date: Wed, 29 Sep 2021 15:48:23 -0700 In-Reply-To: <20210929224823.556943-1-rajatja@google.com> Message-Id: <20210929224823.556943-2-rajatja@google.com> Mime-Version: 1.0 References: <20210929224823.556943-1-rajatja@google.com> X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog Subject: [PATCH 2/2] usb: hub: Mark devices downstream a removable hub, as removable From: Rajat Jain To: Greg Kroah-Hartman , Alan Stern , Rajat Jain , Thinh Nguyen , Mathias Nyman , Andrew Lunn , Chris Chiu , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: levinale@google.com, bleung@google.com, rajatxjain@gmail.com, jsbarnes@google.com, pmalani@google.com Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org If a usb device sits below a removable hub, mark the device also as removable. This helps with devices inserted on a standard removable hub or also thunderbold docks, to be shown as removable. Signed-off-by: Rajat Jain --- drivers/usb/core/hub.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 45d1c81b121d..901d74bcdbd9 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2449,6 +2449,13 @@ static void set_usb_port_removable(struct usb_device *udev) if (udev->dev.parent && dev_is_removable(udev->dev.parent)) dev_set_removable(&udev->dev, DEVICE_REMOVABLE); return; + } else if (dev_is_removable(&hdev->dev)) { + /* + * If this USB device sits downstream a removable hub, then mark + * this device also as removable. + */ + dev_set_removable(&udev->dev, DEVICE_REMOVABLE); + return; } hub = usb_hub_to_struct_hub(udev->parent);