Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1363620ybl; Wed, 4 Dec 2019 23:33:54 -0800 (PST) X-Google-Smtp-Source: APXvYqz558gfkn+ygaYBUU6JR/NPhTrQ8NHGxstLBmAa04tgQBaAd+32ajayWZz/TKYy1EGfy8cv X-Received: by 2002:aca:f445:: with SMTP id s66mr5810201oih.95.1575531233962; Wed, 04 Dec 2019 23:33:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575531233; cv=none; d=google.com; s=arc-20160816; b=J//bodpcCvhXFmoHyIZRpzmagIBMqCW4hYMMg9mQdzQW3qPVjXd15wHfsXDC9RzkZm 9jkXyigcrbRU9OQtDPp6d1CTBpC/YJyYqO/Slq++90IITWEP/8X+zLk9GnyjFY+FBWKD S23N0k1oO4ZnOej2nR5lfKC6Y5ZSBdQF7aE0NW/ATJWfNrQXDsmOXumUIGBOJfKctH4Y k2Isa1TAV1Dn3Fk7c4XqeKcKnvdqGqJOHMcm5Xtjhe5osePvcnU75B2FNJe3kUM60t41 cUZr3WkPeqwFB7JZO1ndM5B/rLPiq+OEqBsfgGVF9t86KGiCxCuqyfjyUC7Zz61cOOF4 Zp+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=KsELQrnPZOtejoY9i2DcdQh6UW42pUNNIY62CtBGNDc=; b=0lKPCq5UxmtxEFfj1x8Wja+AGiC66iWjH19xr7jFvXTFwNxQ6PyZUSAxVqd3mb5yo5 JnQgrdh6Esowz/IdYuiVBSgv8FMIJN+nNqDjz9+yE8dI2Xc3d/AAiwPwkcSp/txpTa7W VnIbRGaJgRjWdLXnHtiR8SicCoJSTRIANzTq8BdnpRIqFszBNDQlLuB4eiAcjyLHkY/R sWevU2qI0dvonBJ4Hs4gyWWWWUQDaW1sEeYQdqEBYJJ6Tm4VpIaXZK+ELERRMf9+5Hmu gw1Tio9y/U+WCETvyghCpiWwYEOC3Ijaw2br6o76py+41Kiz+lgAXXF+II3HjUJn2sY/ P1Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=K8ZOZvMX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z194si4613270oia.50.2019.12.04.23.33.41; Wed, 04 Dec 2019 23:33:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=K8ZOZvMX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726069AbfLEHcv (ORCPT + 99 others); Thu, 5 Dec 2019 02:32:51 -0500 Received: from mail-ua1-f67.google.com ([209.85.222.67]:39929 "EHLO mail-ua1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725953AbfLEHcu (ORCPT ); Thu, 5 Dec 2019 02:32:50 -0500 Received: by mail-ua1-f67.google.com with SMTP id r13so865770uan.6 for ; Wed, 04 Dec 2019 23:32:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KsELQrnPZOtejoY9i2DcdQh6UW42pUNNIY62CtBGNDc=; b=K8ZOZvMXPg14WS3fQd+RBECESqh0GW7rIgK55uh1NaVW8NgJN3M4lK6gsY58FUpz3r 579brr/4qJcNLtpDf/74ELIW4MFLn9VdIRC7C49tRzxW9Sw4D4hxc5fCDlJJ/GRcXRKD rH4zot3jChLf4F049+6kdx643bIVmP2Zlkd7E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KsELQrnPZOtejoY9i2DcdQh6UW42pUNNIY62CtBGNDc=; b=ejf+TlaoJrJr44uxKwQYwZBncItfk4bIMZGUqd4/E0tHNQ+x6bba9AlOCSYczjvKMc vteI6RJ+XnOKFfyZTYlvFoYxKv7fXTocbV8N9AGnYXr5RL5fzFN6ql0cLcNQg8wA1hDw IE1+iTJMtV/fJ2s2KiYIz/CK0QFswvM+RZczvgP8zT2yT0Q3Zt5Dzrf0FKCFPZbgjLGO B9LCeex65AzQldj+89MBeVBcCGynRpv8m+TWf3M3ver9GLuU6NeIAr0f7Mta963iPLK1 qJ7BPf1HtW/ZT1QFw2lB1PnntPbzyiamcP2WR2qxteHFtUe5WqTVs6bDMlRsmvTMAx+A umyw== X-Gm-Message-State: APjAAAXTzkBupNr/BMgm7mVkoDnqTlJf6ChJTmvm416SwpCb83hYXbF6 YJyQQNzsVGQjf+P8fknve1lNyLwKR86swUmAj8rz3Q== X-Received: by 2002:ab0:3487:: with SMTP id c7mr4227890uar.25.1575531169645; Wed, 04 Dec 2019 23:32:49 -0800 (PST) MIME-Version: 1.0 References: <20191203101552.199339-1-ikjn@chromium.org> <20191203165301.GH10631@localhost> <20191204075533.GI10631@localhost> In-Reply-To: <20191204075533.GI10631@localhost> From: Ikjoon Jang Date: Thu, 5 Dec 2019 15:32:38 +0800 Message-ID: Subject: Re: [PATCH v4 2/2] usb: overridable hub bInterval by device node To: Johan Hovold Cc: linux-usb@vger.kernel.org, GregKroah-Hartman , RobHerring , MarkRutland , AlanStern , SuwanKim , "GustavoA . R . Silva" , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Nicolas Boichat Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 4, 2019 at 3:55 PM Johan Hovold wrote: > > > > @@ -257,6 +258,14 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum, > > > > memcpy(&endpoint->desc, d, n); > > > > INIT_LIST_HEAD(&endpoint->urb_list); > > > > > > > > + /* device node property overrides bInterval */ > > > > + if (usb_of_has_combined_node(to_usb_device(ddev))) { > > > > > > Not only hubs have combined nodes so you probably need to check > > > bDeviceClass here instead. > > > > yes, you're right, I didn't think of that case: > > if (to_usb_device(ddev)->descriptor.bDeviceClass == USB_CLASS_HUB && > > ddev->of_node && !of_property_read_u32(...)) > > > > Or is it better to check bInterfaceClass, for composite devices with a > > hub interface inside? > > if (ifp->desc.bInterfaceClass == USB_CLASS_HUB && ddev->of_node && > > !of_property_read_u32(...)) > > > > I think checking bInterfaceClass is better. > > Yep, that seems better (but please use two conditionals for > readability). > > But related to my question above, why do you need to do this during > enumeration? Why not just set the lower interval value in the hub > driver? > Because I want device tree's bInterval to be checked against the same rules defined in usb_parse_endpoint(). e.g. although hardware says its maximum is 255, but the practical limit is still 0 to 16, so the code can print warnings when bInterval from device node is too weird. > > > > + u32 interval = 0; > > > > + if (!of_property_read_u32(ddev->of_node, "hub,interval", > > > > + &interval)) > > > > + d->bInterval = min_t(u8, interval, 255); > > > > > > You want min_t(u32, ...) here to avoid surprises when someone specifies > > > a value > 255. > > > > yes, thanks. > > And I guess you should really be honouring bInterval as a maximum value, > right? Yes, right, not masking. > > > > > + } > > > > + > > > > /* > > > > * Fix up bInterval values outside the legal range. > > > > * Use 10 or 8 ms if no proper value can be guessed. > > Johan