Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp12161985rwl; Tue, 3 Jan 2023 09:53:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXuWLS9eYp2KXZgt74V/WobwS4uskJyJYODUnMrkntYU1DppKPBYVE+fstEr3NDOs/ApRPcH X-Received: by 2002:a17:907:d109:b0:818:3f54:8df7 with SMTP id uy9-20020a170907d10900b008183f548df7mr49816950ejc.2.1672768424958; Tue, 03 Jan 2023 09:53:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672768424; cv=none; d=google.com; s=arc-20160816; b=d9nEkglyyXlu7aRLuDrB1E7v1mPYyx6+G6T0RHt7PTEnbDwmMeAkowL94jD+ej3aCf 0vDM0pAXLcrK5nL2tTqU2/k8wv5ZuqZD7B84IZrX0OZGDl3ZL6kjP5Q8UeVO5QXRwNST 8OZ5DWyUjrZ8mEDeE1S3ZCdLS6UruJmrP4FFe/8aVK2vJxb6r0Z1xHri3MBxiFiTUDJN HB/UgkoVScYK1/LKzxyPwmwMV85576pYHFtwlbV7xMcdzA3kWP5LTdljxA43PmxaDnNH xpfob/Xl9hIlBHc5KZLoHUd91w0L5efaSqavnnY2134ybPfCmqTetJLyWThsTjk24035 548Q== 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:dkim-signature; bh=em3Ufd1K4FFk6wUY+M7YROP86iN6cIDpfsX/6JZ8LMs=; b=WE6caSu7Pl2hGAtMyYpkx6w6KI3XTpPlB9O9QOaJfuyhvK7IPvU2gB9NWW4tWL5PcN 0ZOtmGlBgITt8F5pqecespmkHK5zQxrD7WUTJypRqCfzP6aQzq474ZTPDCDGGlRvgqHl BOup5BTv0VU3HyeUa+aneHph5z9NK0Ulfob4Nw+q5RXtUMzJAITKOiCQCHAra8HUH4xr HwEio7Isexz0gzdH3CkkmgUPyLHJeo5gTvcbVstf39Vszm14iz0QzzfzN7qbsmC/Rwdq fJWOMvZ0Vv2ixiWqAv7hq5EIz83pOlYz8oxVPC62YahOGPqLGckp0W/SSxahEFWyAhaC 3iDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=IxtRL1xI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn8-20020a17090794c800b007c4f6c371a8si31034001ejc.519.2023.01.03.09.53.28; Tue, 03 Jan 2023 09:53:44 -0800 (PST) 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; dkim=pass header.i=@chromium.org header.s=google header.b=IxtRL1xI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238458AbjACRNl (ORCPT + 60 others); Tue, 3 Jan 2023 12:13:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238440AbjACRMq (ORCPT ); Tue, 3 Jan 2023 12:12:46 -0500 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18A46F0E for ; Tue, 3 Jan 2023 09:12:26 -0800 (PST) Received: by mail-io1-xd32.google.com with SMTP id h6so16885306iof.9 for ; Tue, 03 Jan 2023 09:12:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=em3Ufd1K4FFk6wUY+M7YROP86iN6cIDpfsX/6JZ8LMs=; b=IxtRL1xI/M7DHv6CuM2XNgJ63pduHqi4eG8on4E2MOZfzDFgtSQ7zMJJJBh990hFZh WAkVgsQn71Z2e1DpUiHQwLMpfiHRniYn3qeCgE4Dw+j7gyxO7wsTBc19pQcUTmhVrx2d /tz4xiyHI9iTo95NWoWI3W3QryAVA5l3HhbbA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=em3Ufd1K4FFk6wUY+M7YROP86iN6cIDpfsX/6JZ8LMs=; b=2eCEia8g9mbje2HUrKgAaC59wsOUjPIxyPKZD0efbsd7Arl0Mj3EEkpx5GAaCU/LOD 5kvCfwlzW/ifJrUrsUgYiWl2vc6EF2BstpfuUoyiqohwT1aQ6e2/NrneblfYrtg6meyk Keea957cyj0CAyubZyTYyEQi8XmSidDAmw+wU5anyPOTbETOpntWrF4Nluh4QUNCOsRN sQmzi8KJMkWpApp/qthCStD9ZP/0Z0GUVNQSlI8ueTHnhmnEQMQIPUw3a0q5i/qhK6yK pCaN1ZAuMfZ2RwfWOJ3ymX0784vZODMYhJH90ZybIO3ECBP6wRdWtieYPaVlkqUr/NvS 0Yrg== X-Gm-Message-State: AFqh2krobm1e8eJNQCaU86zcDTKXocKyOBow9c4b8iDC5oI5pZPmc+Uc IGf3iyiinu77Iv+zWlkHduK+sA== X-Received: by 2002:a5e:8d1a:0:b0:6e3:21fd:6783 with SMTP id m26-20020a5e8d1a000000b006e321fd6783mr27731823ioj.2.1672765945209; Tue, 03 Jan 2023 09:12:25 -0800 (PST) Received: from localhost (30.23.70.34.bc.googleusercontent.com. [34.70.23.30]) by smtp.gmail.com with UTF8SMTPSA id x6-20020a056602160600b006e00556dc9esm11407972iow.16.2023.01.03.09.12.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Jan 2023 09:12:24 -0800 (PST) Date: Tue, 3 Jan 2023 17:12:24 +0000 From: Matthias Kaehlcke To: Doug Anderson Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Stefan Wahren , stable@vger.kernel.org, Ravi Chandra Sadineni , Alexander Stein , Icenowy Zheng Subject: Re: [PATCH v2 1/2] usb: misc: onboard_usb_hub: Don't create platform devices for DT nodes without 'vdd-supply' Message-ID: References: <20221222022605.v2.1.If5e7ec83b1782e4dffa6ea759416a27326c8231d@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 Thu, Dec 22, 2022 at 11:26:26AM -0800, Doug Anderson wrote: > Hi, > > On Wed, Dec 21, 2022 at 6:26 PM Matthias Kaehlcke wrote: > > > > The primary task of the onboard_usb_hub driver is to control the > > power of an onboard USB hub. The driver gets the regulator from the > > device tree property "vdd-supply" of the hub's DT node. Some boards > > have device tree nodes for USB hubs supported by this driver, but > > don't specify a "vdd-supply". This is not an error per se, it just > > means that the onboard hub driver can't be used for these hubs, so > > don't create platform devices for such nodes. > > > > This change doesn't completely fix the reported regression. It > > should fix it for the RPi 3 B Plus and boards with similar hub > > configurations (compatible DT nodes without "vdd-supply"), boards > > that actually use the onboard hub driver could still be impacted > > by the race conditions discussed in that thread. Not creating the > > platform devices for nodes without "vdd-supply" is the right > > thing to do, independently from the race condition, which will > > be fixed in future patch. > > > > Fixes: 8bc063641ceb ("usb: misc: Add onboard_usb_hub driver") > > Link: https://lore.kernel.org/r/d04bcc45-3471-4417-b30b-5cf9880d785d@i2se.com/ > > Reported-by: Stefan Wahren > > Signed-off-by: Matthias Kaehlcke > > --- > > > > Changes in v2: > > - don't create platform devices when "vdd-supply" is missing, > > rather than returning an error from _find_onboard_hub() > > - check for "vdd-supply" not "vdd" (Johan) > > - updated subject and commit message > > - added 'Link' tag (regzbot) > > > > drivers/usb/misc/onboard_usb_hub_pdevs.c | 13 +++++++++++++ > > 1 file changed, 13 insertions(+) > > I'm a tad bit skeptical. > > It somehow feels a bit too much like "inside knowledge" to add this > here. I guess the "onboard_usb_hub_pdevs.c" is already pretty > entangled with "onboard_usb_hub.c", but I'd rather the "pdevs" file > keep the absolute minimum amount of stuff in it and all of the details > be in the other file. > > If this was the only issue though, I'd be tempted to let it slide. As > it is, I'm kinda worried that your patch will break Alexander Stein, > who should have been CCed (I've CCed him now) or Icenowy Zheng (also > CCed now). I believe those folks are using the USB hub driver > primarily to drive a reset GPIO. Looking at the example in the > bindings for one of them (genesys,gl850g.yaml), I even see that the > reset-gpio is specified but not a vdd-supply. I think you'll break > that? Thanks for pointing that out. My assumption was that the regulator is needed for the driver to do anything useful, but you are right, the reset GPIO alone could be used in combination with an always-on regulator to 'switch the hub on and off'. > In general, it feels like it should actually be fine to create the USB > hub driver even if vdd isn't supplied. Sure, it won't do a lot, but it > shouldn't actively hurt anything. You'll just be turning off and on > bogus regulators and burning a few CPU cycles. I guess the problem is > some race condition that you talk about in the commit message. I'd > rather see that fixed... Yes, the race conditions needs to be fixed as well, I didn't have enough time to write and test a patch before taking a longer break for the holidays, so I only sent out this (supposed) partial mitigation. > That being said, if we want to be more efficient and not burn CPU cycles > and memory in Stefan Wahren's case, maybe the USB hub driver itself could > return a canonical error value from its probe when it detects that it has > no useful job and then "onboard_usb_hub_pdevs" could just silently bail > out? _probe() could return an error, however onboard_hub_create_pdevs() can't rely on that, since the actual onboard_hub driver might not have been loaded yet when the function is called. It would be nice not to instantiate the pdev and onboard_hub USB instances if the DT node has neither a 'vdd-supply' nor 'reset-gpios'. If we aren't ok with doing that in onboard_hub_create_pdevs() then at least the 'raw' platform device would be created. onboard_hub_probe() could still bail if both properties are absent, _find_onboard_hub() would have to check it again to avoid the deferred probing 'loop' for the USB instances. Alternatively we could 'just' fix the race condition involving the 'attach work' and the onboard_hub driver is fully instantiated even on (certain) boards where it does nothing. It's relatively rare that USB hub nodes are specified in the DT (unless the intention is to use this driver) and CONFIG_USB_ONBOARD_HUB needs to be set for the instances to be created, so maybe creating the useless instances is not such a big deal.