Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp2946rbe; Wed, 28 Feb 2024 10:11:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVVkVThvbhx5/b61fLiApCChOs3dOTNlfQb3wpTx8IXWtT0oHkjNibTHPoBSRKyP9GFTDHcxhmVSAxXk6EEEQY5+xVbrj9+BApPQPQJlQ== X-Google-Smtp-Source: AGHT+IGqEBUq5PYTBcg2muy9Ch7yUgqIZK+1pSl80bREB2HRvNZYi1UPDS1smXc97bq7R1CTvQfd X-Received: by 2002:a17:906:344a:b0:a43:f825:ef52 with SMTP id d10-20020a170906344a00b00a43f825ef52mr338773ejb.28.1709143862010; Wed, 28 Feb 2024 10:11:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709143861; cv=pass; d=google.com; s=arc-20160816; b=0g43QZWdss6g+mvtUod5JR/t5spYjyNnGezW/dWiB0J6KMmpjJTrzQnSwxBukvtIEn yjxyJbWZsphYUkJ/x59FrS9JXR6CkEW+8h9YJAD86pqhSs7lh0qzAkBiO5wvi0LDZj3J voq23U/BMzMHohnKa4vOSqU7/h/CAr12Ea6YQ6JibvAYc/ayviBKxY/paoVIvhIqbv76 LU8ynZxr8ztjJUUOvqpznKwO3AdQaSiJaftulHCmEJDuH4IlSo9osVy6LjLRbaknm3+p HqJyCU5xJ6eJI3I8LsxQlUvkaC2LdJEy1fKviLoABkDs+GcYYVYdTk8SV24tFdOs+ebW wa1g== 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=mr+bD36IoIOKszW1o5Rb9R/mzBzmVVAn2qquBqx2Jtw=; fh=uO4a0SA5X1tlSr8onV0uZYo5MRnZSgQdTQyow5xovCg=; b=k2xNBeMxd8d33ksblRCZkz2LozFik0wwF64Tcg18xM8mLnpVcxO6t+kTxa4KEpgJqm dvFBj2X009TYHtnny/B4fg0Xvkg4ISdoCetiOJabufEbksfp8jxwFG3iwm8B/W/fWhBV /1JOIvkOYAKjy8xh/l97EadJgzViK/I3V9ztt3gpWljSDpUbVqTxcVar+RkkQYRxf+qA mR/outXm2c/x00lOTlGmaZcKcG3gjtkuS/T80/d4SCzewVVKHnuOLnsYUutmHQ+/CGvR b24b4XNQx4KPMADEZDAKqjer9dDdKstpMhc//2BgB2dtx4w6y0W4OFbUat/OSiSgIkqD m87w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FEIYouPg; 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-85511-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85511-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. [147.75.80.249]) by mx.google.com with ESMTPS id cb17-20020a170906a45100b00a44133accb0si485852ejb.872.2024.02.28.10.11.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 10:11:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85511-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FEIYouPg; 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-85511-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85511-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 C21B51F26EB3 for ; Wed, 28 Feb 2024 18:11:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 923BF3FBB4; Wed, 28 Feb 2024 18:10:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="FEIYouPg" Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) (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 E630479B84 for ; Wed, 28 Feb 2024 18:10:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709143850; cv=none; b=k1zQ+7I+xXsrFC/m7CPBP3FjD2dTopgWiRgzzM0sFJXucYBm2gjMkjAQt/nGSvsoN3RF0POcUZj6ptwZS5eMZIZ+XXvZRkvue4xh0PVr9ibVP+PWviLXUtxyhHslEC650DyU1XcMUA0vtnFV53wuPOsPA+xQToJaRNly0QC9//0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709143850; c=relaxed/simple; bh=ydPMob62Ut9r97Sqx0kikCCPdrTngYvBh6QQJWZzIis=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=s+LYeU49WiPYTHn6FYs1vZt65s2eG1Kr46mgz0/vJr00QSd/wCIglw0ANXWeDgPudu+kNgny1rhzYNmdpMVdAiA5ORFe/dfHpacdHhMtNYS1HAy9i9rYusbnQmjQRu+ANSb8owGKINYgjNR23dV4kUKxhE9Bg214Bv1pKd8A7T0= 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=FEIYouPg; arc=none smtp.client-ip=209.85.166.174 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-f174.google.com with SMTP id e9e14a558f8ab-3652762edcfso327905ab.2 for ; Wed, 28 Feb 2024 10:10:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709143847; x=1709748647; 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=mr+bD36IoIOKszW1o5Rb9R/mzBzmVVAn2qquBqx2Jtw=; b=FEIYouPgnFUzrWgIdZQASk0HWhUcQiarax30evBDsqyfoRmttaihpZYlAXELZtupH3 WLBwen2wkwlwXrRIqLYjRAvbfPShC+vVCVo4S5UFkQLCxPRrjDUvRwqYufqDJ8oZKq/f Hh69pt0BOR0N6tTt5CByS7vnCSxNSo5TYHS3o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709143847; x=1709748647; 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=mr+bD36IoIOKszW1o5Rb9R/mzBzmVVAn2qquBqx2Jtw=; b=xOISa6Pgc/pmccVsNhZpoIxlgAc6myiXvhyhny8LMEH7vB/lFwSrAITimya96hOAl8 ydboMplG1G/OnfZPrVNomYv862xwXbkr78JYRywLxAeNeVimQSr5M4LZuU0xw2YYfErt lNjtNKVpvpZUgXRPzlYYrUP5PxD0ZEd6OCJVcZljrvktQbb34QQvYdTlhDqRB+O9J4zw nmumLFFkB7BQwwSH0sjoAqzbPzqT7xrFI9gXVgVwOB1IndQsfaIXB81rz1STVe6iBewn swf7PPytZzpgMQrRrfS1cEI/sqByCOQ0su0iUBS7FKEMOA5BQD9FhVhLGYLa3ZgIUfLv 2jHA== X-Forwarded-Encrypted: i=1; AJvYcCX+1XV9VKUMQknMPvgvR2ulTEpSSmJ1QRXS+8f0GJkeK7Q/bKBUBA/GEfzL+4wypffEDzFlqWvcNc4YePIAXXrnEe4FPDcRnXS4e7gs X-Gm-Message-State: AOJu0Yy2DCf+xmc6nqnAMnKO1UXN/LsNFnnWPTEojyKc/SbyatbVWN0Q 5JFzjd2MkHhtuqJiJ5YHx9XkcadbKeKSI763MLfflUTEIMQAqhPwLvfM8LW55Q== X-Received: by 2002:a92:dd04:0:b0:365:b9c8:4436 with SMTP id n4-20020a92dd04000000b00365b9c84436mr25912ilm.10.1709143847146; Wed, 28 Feb 2024 10:10:47 -0800 (PST) Received: from localhost (144.57.222.35.bc.googleusercontent.com. [35.222.57.144]) by smtp.gmail.com with UTF8SMTPSA id bp24-20020a056e02349800b00363da909ebcsm2915892ilb.56.2024.02.28.10.10.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Feb 2024 10:10:46 -0800 (PST) Date: Wed, 28 Feb 2024 18:10:45 +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: <20240228-onboard_xvf3500-v5-6-76b805fd3fe6@wolfvision.net> 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: 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. 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.