Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp77269rbe; Wed, 28 Feb 2024 12:42:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXdmZgLbV2pF9QK0XmsbbFdMXdKXA2OaVRsXvvcrsB+gZumOgAbMED16XQtPhBtaU/pJ5MmmVCeg7yV1njVpgqm5/yvuAxzMQuHrPwzfw== X-Google-Smtp-Source: AGHT+IHtAM799gcgZl04wW1RPEI83j+EdHTceywOiqbBvumfIv0ANRtbfpI8hYYNnWg7xEdGN127 X-Received: by 2002:a05:6402:32a:b0:565:df8c:6a27 with SMTP id q10-20020a056402032a00b00565df8c6a27mr57776edw.20.1709152967088; Wed, 28 Feb 2024 12:42:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709152967; cv=pass; d=google.com; s=arc-20160816; b=Femdi0qgXejcP20D1hLflyMjU0ZdERTbONdrcWSKgrMSPlTyGF/GfsB9WprT4IQf/j cmDC2ePJgghzzkCXcqxW70RSA+aL1KYFus9YrGTlTwDx5NckZJwEZRtf2u6XkazGGDUF zLu8hs58KkqYqhhKdQGJ5FI4JvNbZuETcdr0O5a2LO7i0aqK/3m3DnHhtGqdqeA+4PdJ DyR1N8opGfMcdp46cf1GXJT0zHpgb+WwvoV3B4vh5Ar0C33ZSeoD0mipRxV9tH+CMLA8 1mjdexahPx4UIciolMqLAPVldk60o2iykVL6kUeqyQU2NKEsjw06/VZTtCYY1V0yU37Q orVg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Baw+xs3ggfXLm4MxOGqTtw4oYWjUFXR4qcJc+3eX6ws=; fh=JBIfdFIPuOqOBTBdXJr3+1hQtH6qqt8wx3u8MJ9NLEs=; b=AWr4NULnyYeEDGJXYHXkLLGq6gEZCufRwFhWiW6Ygmg4SkK9C18lRurL0mpyeEf/4z p+IfhNtqbjXgFbTlTZjDxWODDz8byu+7jIeZ3h3P2TcWve/VlHvzFH8YgXznMK+8CdUC ptM8kWrYIItogUCxFmfQdwmJ95duJqliGpdzJATTx/iRCEvpM07k2smaD/SWE/dH7N+y wZc8WbbiqT0ai9afqz139pjgzpDZRpSZEk/nL11YnUbfaPPw1V1tbkuErAaE73PiyuFc YtMjqk8LaruYi44xrvfyovMbMCy8shIRRElwkW5FWCFzoMMDj6fAadtuBjMrE7WCbtJm Y8bg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PeL5ChEN; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-85681-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85681-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g12-20020aa7c58c000000b00563fbd1bb6bsi1886180edq.336.2024.02.28.12.42.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 12:42:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85681-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PeL5ChEN; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-85681-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85681-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4C2BC1F26162 for ; Wed, 28 Feb 2024 20:41:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B19813541F; Wed, 28 Feb 2024 20:41:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="PeL5ChEN" Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C37C79B7A for ; Wed, 28 Feb 2024 20:41:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709152906; cv=none; b=oivXx4i+W/61creqxJA5ekSNXwzGQXC3T/5xwvNUZBvFRVGro0HnITM8zwX3qSEROubVZcqNAGHyMUUCNYoemEIL1SNseU8B8L07E5wxGhO48d+27vf0ild0gQjmMXMJp228x0cwcUgSvwTCjE48xWG0jeep+QU2lDMGGRSX+2U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709152906; c=relaxed/simple; bh=pcrCq/2jEzxjqO0m+FR7FzBK48L/+Z3u7o5R0CChEoI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=s1p2kkjMsE7yrP90/zpTWBbLZoIl6gZKx53ay/w3KIRFCdOU3pHb5wZn4zYC5CeeZKZzJcR0dwGhtYcNWEgX0VE5yXda+yg+gC06alpZ6jOLeb9AWc26DdFmSg4VM3H+c+uams4QD0qxgVcutoVqofOKRR5t4PAz8oosWNQfDEI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=PeL5ChEN; arc=none smtp.client-ip=209.85.166.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-365b3bab179so987825ab.0 for ; Wed, 28 Feb 2024 12:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709152903; x=1709757703; darn=vger.kernel.org; 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=Baw+xs3ggfXLm4MxOGqTtw4oYWjUFXR4qcJc+3eX6ws=; b=PeL5ChENXb/lS++fPGAAdSCTb40BJTR75CLLKyuXEZmYmsllC/sql4V7UKLhRB7SnI Rw/lGy041Oy1nF6oKsFrn7uYsUz+eEaRBz0LfzQnYV0ODBmmDn3gDOBeliV6dzRQ62UR ntukuh/VjS4Ru03IBBsjfnTPH3R/fL7wGw7u8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709152903; x=1709757703; 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=Baw+xs3ggfXLm4MxOGqTtw4oYWjUFXR4qcJc+3eX6ws=; b=OSNuASczI4znLGq+H80FJDjcFGYikkgrkMCwzt6PLYVnv3mwwAJQ238n0ejGfyCKU8 bqy97zOwALH2UnAnzw8nGEeSGx/siJSlrH+QBQquVWt3v8K5FbVeMIVTbkY3IgDB8NWn i4cjU/IN1OUC1SvAn63Be+/dIZynKsraKIz6FlyulySaw/v0oHFNvsYDGW0UYRX6XF2l 9RFMbzVW5lR7cb8QgPMhHCUt9QrVm4HqtrYq8x4aob6z0A42rQHVFTJlUp38nq+mhF6q byKbLye4wCmnyDqaeA4qQohSibqoYgOvYVio1glJNS9wT15UaUs0YaxIAeeJtu6AbFzI mYUg== X-Forwarded-Encrypted: i=1; AJvYcCVMU8YjK4cJM6iCwkz1O+RrJPvSlCJFXlyJmjEM0fCt4niHGWzRvJG2rtAsun3zDB5xkDXlJZhZco5zZI/nI8fTzjQFz7L68IkzJ74p X-Gm-Message-State: AOJu0Yz6gkoqaqzEmEP/yDEl+amIkqlLbPn+RfMLlgoFo8XO5eos2OZ/ lxAAAVskBboAyebqi8k7sx0x99ahBB2tbKxHcAw6kvhPWyRPPJRNjLZbqzZnWw== X-Received: by 2002:a92:d2cd:0:b0:365:b5aa:135d with SMTP id w13-20020a92d2cd000000b00365b5aa135dmr322432ilg.32.1709152903571; Wed, 28 Feb 2024 12:41:43 -0800 (PST) Received: from localhost (144.57.222.35.bc.googleusercontent.com. [35.222.57.144]) by smtp.gmail.com with UTF8SMTPSA id bc29-20020a056e02009d00b00364372c5b5asm49554ilb.15.2024.02.28.12.41.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Feb 2024 12:41:43 -0800 (PST) Date: Wed, 28 Feb 2024 20:41:42 +0000 From: Matthias Kaehlcke To: Javier Carrasco Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Greg Kroah-Hartman , Helen Koike , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Catalin Marinas , Will Deacon , Russell King , linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v5 6/8] usb: misc: onboard_dev: add support for non-hub devices Message-ID: References: <20240228-onboard_xvf3500-v5-0-76b805fd3fe6@wolfvision.net> <20240228-onboard_xvf3500-v5-6-76b805fd3fe6@wolfvision.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Wed, Feb 28, 2024 at 09:21:00PM +0100, Javier Carrasco wrote: > On 28.02.24 19:10, Matthias Kaehlcke wrote: > > On Wed, Feb 28, 2024 at 02:51:33PM +0100, Javier Carrasco wrote: > >> Most of the functionality this driver provides can be used by non-hub > >> devices as well. > >> > >> To account for the hub-specific code, add a flag to the device data > >> structure and check its value for hub-specific code. > >> > >> The 'always_powered_in_supend' attribute is only available for hub > >> devices, keeping the driver's default behavior for non-hub devices (keep > >> on in suspend). > >> > >> Signed-off-by: Javier Carrasco > >> --- > >> drivers/usb/misc/onboard_usb_dev.c | 25 +++++++++++++++++++++++-- > >> drivers/usb/misc/onboard_usb_dev.h | 10 ++++++++++ > >> 2 files changed, 33 insertions(+), 2 deletions(-) > >> > >> diff --git a/drivers/usb/misc/onboard_usb_dev.c b/drivers/usb/misc/onboard_usb_dev.c > >> index e1779bd2d126..df0ed172c7ec 100644 > >> --- a/drivers/usb/misc/onboard_usb_dev.c > >> +++ b/drivers/usb/misc/onboard_usb_dev.c > >> @@ -132,7 +132,8 @@ static int __maybe_unused onboard_dev_suspend(struct device *dev) > >> struct usbdev_node *node; > >> bool power_off = true; > >> > >> - if (onboard_dev->always_powered_in_suspend) > >> + if (onboard_dev->always_powered_in_suspend && > >> + !onboard_dev->pdata->is_hub) > >> return 0; > > > > With this non-hub devices would always be powered down, since > > 'always_powerd_in_suspend' is not set for them. This should be: > > > > May I ask you what you meant in v4 with this comment? > > > Even without the sysfs attribute the field 'always_powered_in_suspend' > > could > > be set to true by probe() for non-hub devices. struct onboard_dev always has the field 'always_powered_in_suspend', even for non-hubs, that don't have the corresponding sysfs attribute. Currently it is left uninitialized (i.e. false) for non-hubs. Instead it could be initialized to true by probe() for non-hubs, which would be semantically correct. With that it wouldn't be necessary to check here whether a device is hub, because the field would provide the necessary information. > > if (!onboard_dev->pdata->is_hub || > > onboard_dev->always_powered_in_suspend) > > > > Checking for the (non-)hub status first is clearer IMO, also it avoids > > an unneccessary check of 'always_powered' for non-hub devices. > > > > That makes sense and will be fixed. > > > Without code context: for hubs there can be multiple device tree nodes > > for the same physical hub chip (e.g. one for the USB2 and another for > > the USB3 part). I suppose this could also be the case for non-hub > > devices. For hubs there is the 'peer-hub' device tree property to > > establish a link between the two USB devices, as a result the onboard > > driver only creates a single platform device (which is desired, > > otherwise two platform devices would be in charge for power sequencing > > the same phyiscal device. For non-hub devices there is currently no such > > link. In many cases I expect there will be just one DT entry even though > > the device has multiple USB interfaces, but it could happen and would > > actually be a more accurate representation. > > > > General support is already there (the code dealing with 'peer-hub'), but > > we'd have to come up with a suitable name. 'peer-device' is the first > > thing that comes to my mind, but there might be better options. If such > > a generic property is added then we should deprecate 'peer-hub', but > > maintain backwards compatibility. > > I have nothing against that, but the first non-hub device that will be > added does not have multiple DT nodes, so I have nothing to test that > extension with real hardware. I see, the XVF3500 is USB 2.0 only, so it isn't suitable for testing. > That could be added in the future, though, if the need ever arises. I expect it will, when a DT maintainer asks the hardware to be represented correctly for a device that is connected to more than one USB bus. IIRC that's how 'peer-hub' was born :) Ok, we can leave it out for now. I might send a dedicated patch after your series landed. If a switch to 'peer-device' or similar is anticipated then it's probably best to deprecate 'peer-hub' ASAP, to avoid it from getting added to more bindings.