Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp12199684rwl; Tue, 3 Jan 2023 10:27:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXseyB5xQUkCXSnBOSUAwVCa9ZY8B6tmmjbSPjNHgWpxey4yCiPiv5e0vQIDooQoZcfvyZhQ X-Received: by 2002:a50:d0d1:0:b0:478:be92:3384 with SMTP id g17-20020a50d0d1000000b00478be923384mr42004565edf.14.1672770442760; Tue, 03 Jan 2023 10:27:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770442; cv=none; d=google.com; s=arc-20160816; b=RuvvwBPBQvYGC8Hf4CMF40tCNHyQkcLbZzNeWH/NHsVnZ5sglKe0Qzqoa07b/yZ94F PiYaiRGpxoEQ0QHI50ee9AePEcyS4lVezHFoC7W31knZH/tUW5rlbhPg5Cxb082wubsf 30y/XIWeIHZhRpaoOl8BzlMlXZ/yva4Qy1c6LTR8F+p0uglUvdu38Hp8e+F1AliK7op3 JdJi8WDn4AsBQFbcYCRTsMwDC2dnqphHowNtTf/z7c4NVNbCOMAXg6L+nL8uT2nDqh+h 1MwnNXvYHRUjrMw6C26RZJ07eELiOOde6LtdQWOdcNAmm43/f3Bzfwz6WzeuKvhtbY41 2jDA== 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=SPDvhZ0E+hOADgQrqmkwdgK1yPO4Xou1kXlnqFtt01g=; b=jHS6MRnuSQTEh8BFY1YwUNgfK9h0SG6cS7tbs7gHAI3pEtlfoV1AknTWrhhkNrA0ue EODoxxe/Kwy2TJyIjUdqopO2xCAu0bivojcEIBe3LkDGyFoa2Z2c4x7cw591csryhDas kixa4lnfmKAq9z8/2ddRf3Yq2OWe6UndXmjjKJRP1EUNBG9cOx9QAkkdcLT273/F/MGo v6COtfEoLH+4j/DyxHYak6eUJ6eymH09t8+GLqUa0WoFn1zzoN/D1rWbEx+ibPP/pflK LwKQ8fdY9JrGUkA7Lzwkb4bomsCUUDUi0eS8zBb2Gq7CKraswmOWEzrFaJOME9lGOaZ9 9BXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EAge6w5Z; 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 s12-20020a056402036c00b004697dff9638si25322849edw.87.2023.01.03.10.27.08; Tue, 03 Jan 2023 10:27:22 -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=EAge6w5Z; 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 S238309AbjACRm3 (ORCPT + 60 others); Tue, 3 Jan 2023 12:42:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238270AbjACRm1 (ORCPT ); Tue, 3 Jan 2023 12:42:27 -0500 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4357CE2B for ; Tue, 3 Jan 2023 09:42:25 -0800 (PST) Received: by mail-il1-x130.google.com with SMTP id p15so7370392ilg.9 for ; Tue, 03 Jan 2023 09:42:25 -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=SPDvhZ0E+hOADgQrqmkwdgK1yPO4Xou1kXlnqFtt01g=; b=EAge6w5ZGRKB9REw8JTGWI3X+y6NFbFLA4CE16oprx2LDBAocRw7kt+gIOO8EwJ8Xh Nu7M7XBLVpM+Cy2lG0rwHZyToFl76QRABNZe+cWQhJZWLQJXAwDky/V1pBvlz7Qqjiti 72Mw4YvDaD59xF9DkPjKArKfamDrpeKUc3MlQ= 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=SPDvhZ0E+hOADgQrqmkwdgK1yPO4Xou1kXlnqFtt01g=; b=2uL8/OxMnpV+i//hHKvNoQfAa+ujOed4Ip5oAp/VJ7ryr+Lz6xjJawIqfyP5gAaqdk 5lACwwLir08x/iUH64mtmCKqs/dglHzUvYM1+Nd6jIlzUSZ+VuYMHeXbF9vKzPEhdpC5 llde0Z91uu2CFZ1Cw8cigmoencnZsLtSQ7zRhzb3nSzN+i8FUrHQthzunCXtx3Bo7iF+ Ok1zOMv/G3UbRKXjmWORWUB4xoGPLItA1jy9JElCATCdwiTfKFgg+Z+t6aAYg78vwpC6 S+Ohq6CL+/lSREJMbjEDmQ+k5JvEAeCRdo0lCUA2+q8b4Va53M72tZdVRQ4Agf+MvTpa SjJA== X-Gm-Message-State: AFqh2kogTVDOcEkrGtzuB/wD3LwkD6hKlEsxvY9ASG1ftERYUZtZR0fO Z2CT364OFDtH2yJSr8ZIJ4Ie1w== X-Received: by 2002:a92:d10f:0:b0:305:dee9:bcc6 with SMTP id a15-20020a92d10f000000b00305dee9bcc6mr27345476ilb.17.1672767744507; Tue, 03 Jan 2023 09:42:24 -0800 (PST) Received: from localhost (30.23.70.34.bc.googleusercontent.com. [34.70.23.30]) by smtp.gmail.com with UTF8SMTPSA id g14-20020a056e021a2e00b00304ae88ebebsm9792396ile.88.2023.01.03.09.42.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Jan 2023 09:42:24 -0800 (PST) Date: Tue, 3 Jan 2023 17:42:23 +0000 From: Matthias Kaehlcke To: Johan Hovold Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Stefan Wahren , stable@vger.kernel.org, Douglas Anderson , Ravi Chandra Sadineni 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 Fri, Dec 23, 2022 at 03:01:54PM +0100, Johan Hovold wrote: > On Thu, Dec 22, 2022 at 02:26:44AM +0000, 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) > > Please try to remember to CC people providing feedback on your patches. Ack > > - updated subject and commit message > > - added 'Link' tag (regzbot) > > > > drivers/usb/misc/onboard_usb_hub_pdevs.c | 13 +++++++++++++ > > 1 file changed, 13 insertions(+) > > > > diff --git a/drivers/usb/misc/onboard_usb_hub_pdevs.c b/drivers/usb/misc/onboard_usb_hub_pdevs.c > > index ed22a18f4ab7..8cea53b0907e 100644 > > --- a/drivers/usb/misc/onboard_usb_hub_pdevs.c > > +++ b/drivers/usb/misc/onboard_usb_hub_pdevs.c > > @@ -101,6 +101,19 @@ void onboard_hub_create_pdevs(struct usb_device *parent_hub, struct list_head *p > > } > > } > > > > + /* > > + * The primary task of the onboard_usb_hub driver is to control > > + * the power of an USB onboard hub. Some boards have device tree > > + * nodes for USB hubs supported by this driver, but don't > > + * specify a "vdd-supply", which is needed by the driver. This is > > + * not a DT error per se, it just means that the onboard hub > > + * driver can't be used with these nodes, so don't create a > > + * a platform device for such a node. > > + */ > > + if (!of_get_property(np, "vdd-supply", NULL) && > > + !of_get_property(npc, "vdd-supply", NULL)) > > + goto node_put; > > So as I mentioned elsewhere, this doesn't look right. It is the > responsibility of the platform driver to manage its resources and it may > not even need a supply. > > I see now that you have already matched on the compatible property above > so that you only create the platform device for the devices that (may) > need it. > > It seems the assumptions that this driver was written under needs to be > revisited. The assumption was that the driver should always be used when the DT has nodes with the supported compatible strings. It turns out that is not entirely correct, in rare cases (like the RPi 3 B Plus) the nodes weren't added with the onboard_hub driver in mind and may lack DT properties that are needed by the driver. I see essentially two possible ways of dealing with DT nodes that don't have all the information to make the onboard_hub driver do something useful: 1) don't instantiate the driver when certain DT properties don't exist (the approach of this patch) 2) instantiate the driver regardless. Not ideal, but such DTs should be relatively rare (+ CONFIG_USB_ONBOARD_HUB needs to be enabled for instantiation to happen), so maybe it's not a big deal