Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp120682ybl; Tue, 3 Dec 2019 23:05:46 -0800 (PST) X-Google-Smtp-Source: APXvYqwTI06cBqKwmroPMhpXMDvc79TKrmmigY4RMuR9mHqslJYwvtph5FI1K+e/VwQJnGp7wGDy X-Received: by 2002:aca:1817:: with SMTP id h23mr1389197oih.53.1575443146798; Tue, 03 Dec 2019 23:05:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575443146; cv=none; d=google.com; s=arc-20160816; b=fE/LetZ0uqO46BH+2f0CraeQPIv73ZKpHP8mP7i1aMNbTXGTLqPv6Jv68kubwgOL7O PSY8aXrRcDcIItq81+ZznZf6gflCnH7fNmkFD421GUrKRlG3KHnFy4W38Ry4cmWkb0LC hXFb5SHgGmmIlL3g3r6YhBe8A4+M1tMPJqnAeaBRXe/iO1qOZb54f/qr4JiUBJXURXES TnVckiLXdZ/wBA1MWNuAu+qhAMa/wS2pbel7SFaUQS0ipz8b6C4+gCdxx+94hOi7Tjh5 dYr6BB2KfpcEiulQ6fawUCEJg/VyV5WkOJluFPnr8HgQA4L2US7HLggEUiSh5UnxZrVR JNaw== 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=2ZctKunwgyLMVHuNRAeQfQcDadwdKlFmTmC1zk4+eNo=; b=GLYGM3mliq+ZU1YDwmC/XAPF9bSPCvDfEuJiIJaY4qe+4zJO+XiZulGK9qCG/07JIC cJAYsQyOQbpazIdktApNDr1+ODhEpCokpYIAdTqX0kAPHzOdiliTBcu+FP8uUTmJHz90 RSc5nQooiL3j3pm1WTouQw3qYcI8YcwvJZxal1TMbkztOoxfnB/qdEgwh1ns2DUAZ4Hb 81dHlnTLAfJGLsllotVbVuHvCQMVkH5V4MrRmPWWE/S2pealOGuc8+yASqRPGUFsZe4U 7RL3vp4VdxRY9HU9K5XwCrzgX6nRBzZB9JiCFRPYVsu3oV8IwjywbMes7vI8QEOztFbV fUww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GVFJS0g6; 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 x3si2832466ote.17.2019.12.03.23.05.34; Tue, 03 Dec 2019 23:05:46 -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=GVFJS0g6; 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 S1727149AbfLDHFG (ORCPT + 99 others); Wed, 4 Dec 2019 02:05:06 -0500 Received: from mail-vs1-f65.google.com ([209.85.217.65]:38107 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbfLDHFF (ORCPT ); Wed, 4 Dec 2019 02:05:05 -0500 Received: by mail-vs1-f65.google.com with SMTP id y195so4179307vsy.5 for ; Tue, 03 Dec 2019 23:05:05 -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=2ZctKunwgyLMVHuNRAeQfQcDadwdKlFmTmC1zk4+eNo=; b=GVFJS0g6vusTIy7E8yDWR6wEBrqyHeA/dvrCjpzmFkRp6jwsN7tfaDhypIWgm+48GS ajWWcNcJDaP2rqZnhxN0+YUkHQ3gIRQPwRr/haAfv4I3YFxFfrDZKdSoy38RzQzG2bZl Q7CT8OHqOU2HIL1zI4nORvbwbSgfYgOvxu1nc= 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=2ZctKunwgyLMVHuNRAeQfQcDadwdKlFmTmC1zk4+eNo=; b=XkoAsi8Dcb6eT7spSri4dSYGY7sF23pcQhCSc861NH1koaORTftCZBNPy3iBUvre5C byR4HJum3ONvqqL1Yxxhb4wizOpb89M3ivUp4GZRnE1keuJzhwtHpPDTqRS4aGbHF/m3 pZrgnRJWUNGUXfUhOdeMjnz1FuHGhAqMlJ5WWxzlEJ0HqK6p824OgPfbXGaSedinTYHH RQ4OA3PIzZ9u23J66TaWh5b7Qho6t+kfF7humLtkYo7d3hdu+dBmZTJFFF2zW1U1uVTc C3MWeh9pvLtwQhnGBQo8J/2+Aqc+nXldYvVTNm7hp8VKb4Fs5pulLIArbAymDqQLU80x VeWg== X-Gm-Message-State: APjAAAWqiVOPzRBXGM/RZ7PlJy3vNMTDTLOE82yxG7LZ/416p8Sqr+f1 59pwNj7oHIeIqMVm6pbnhPl/I5TBKTPaY8ShW2fu4g== X-Received: by 2002:a67:f541:: with SMTP id z1mr674820vsn.70.1575443104903; Tue, 03 Dec 2019 23:05:04 -0800 (PST) MIME-Version: 1.0 References: <20191203101552.199339-1-ikjn@chromium.org> <20191203165301.GH10631@localhost> In-Reply-To: <20191203165301.GH10631@localhost> From: Ikjoon Jang Date: Wed, 4 Dec 2019 15:04:53 +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 12:52 AM Johan Hovold wrote: > > On Tue, Dec 03, 2019 at 06:15:52PM +0800, Ikjoon Jang wrote: > > This patch enables hub device to override its own endpoint descriptor's > > bInterval when the hub has a device node with "hub,interval" property. > > > > When we know reducing autosuspend delay for built-in HIDs is better for > > power saving, we can reduce it to the optimal value. But if a parent hub > > has a long bInterval, mouse lags a lot from more frequent autosuspend. > > So this enables overriding bInterval for a hard wired hub device only > > when we know that reduces the power consumption. > > I think I saw you argue about why this shouldn't simply be configured at > runtime. Please include that here too, I can't seem to remember why... Okay. > > > Signed-off-by: Ikjoon Jang > > Acked-by: Alan Stern > > --- > > drivers/usb/core/config.c | 9 +++++++++ > > 1 file changed, 9 insertions(+) > > > > diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c > > index 5f40117e68e7..95ec5af42a1c 100644 > > --- a/drivers/usb/core/config.c > > +++ b/drivers/usb/core/config.c > > @@ -6,6 +6,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -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. > > > + 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. > > > + } > > + > > /* > > * Fix up bInterval values outside the legal range. > > * Use 10 or 8 ms if no proper value can be guessed. > > Johan I will send v5 soon, thank you.