Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp153213ybl; Tue, 3 Dec 2019 23:56:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzNM5Gm9gD2yVy0wqoXsS2D1zh9vL9jDJOa/vipXdrvDhaviVCln0hRbii3jS9hZ/asP39Y X-Received: by 2002:aca:4a08:: with SMTP id x8mr1543371oia.39.1575446192311; Tue, 03 Dec 2019 23:56:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575446192; cv=none; d=google.com; s=arc-20160816; b=R5R872pk3lxpqr+hqGo9uPJGgEOd+OoSB7MnXCi/Pbp1aBFVnCaAC3JUu2sTK7vN/Y 40BcOmciuz4dX3Gs9zD3KnYDs8IcHuekBpyFWg9vI/xF9FlkoWzEukYBs+WYIdGdCYCD yKwAUBDvnRFSF5knbkh7GTl4f0EGHBwBg323+ZKm076jG4917xSeB6DA2T0toIsHmAb8 pEGTLTplCaAvMamRwith5+5BEO5sI64NXOfi2R9MFx5bx3Wz2PprPdaMEhWbSUVZ+0nd 5SqlZdv880FY7RPlZI6I89Bk39BTJI7uORYkmYEgdd5Wb3YBXYkQWdDqB5XgZLQLzgY4 eMPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=HtkivZBfXW8xPuS5rhk5w6nuW6W4kAYRPy9pdM4dJ+E=; b=C3lYRgFVdme4N8UJWi+UF3o8k18GPuPlGvHYO03ssOnADO48yo7pcYEadhQmuY99F2 IZSkJT1IVweIxISrP4TBBJVTGk+ICOyaYKGC1qzyCBOPd6xP02L+0OcJA0VVdEbTW7Dp uO7UmfCImC5Mj1MSMReHyNz6nqQmPD+rya41o09RC43KuYD8lipN+wYKAub05GfZ9SOo CdzfI4kz1UKShOkiAu14/WPOli/mYiuyjIVM6y1soTeGsbnz0NnC4kFab+iMVgDU4HQg AqucJj3w+S8XnRnw5n3p1AJJTzmAjPJbaKzPocajzjDkSvlOudvC8w9EZM/h/PgxeMzr HUxg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o16si3038560otp.289.2019.12.03.23.56.19; Tue, 03 Dec 2019 23:56:32 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727433AbfLDHza (ORCPT + 99 others); Wed, 4 Dec 2019 02:55:30 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45880 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726856AbfLDHza (ORCPT ); Wed, 4 Dec 2019 02:55:30 -0500 Received: by mail-lf1-f66.google.com with SMTP id 203so5284457lfa.12; Tue, 03 Dec 2019 23:55:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HtkivZBfXW8xPuS5rhk5w6nuW6W4kAYRPy9pdM4dJ+E=; b=btrEjsK+1YjS66nqCBcUA8vnICeA+hjizys7/ZujzuHIiNl7HH3Bxik8h3axHHIxUW 7QQ11YfImJLjWULvDmNj6po/N8Aq31lSCLU9Ky3OPqXoGnSUg7sbJ8U+7gZBBZftmFIc mNJn6dOHliFL6PIVwVbOitHy9PbA9HuKixRODy9u0ALsAsq0Wd3cSWrcIEzoQhI05K6y 7K2m5xA5NEeHZHBLBVxD4LeoNOPFbHcCVvES8d4SO688FP8A5rqyLOrSn+vQPeuBmn4H 5xGi5ZLLnlKrH/XJKHDArIfHE6/tR2UmHzoAry1M0BEzIUoCxZpP44aeTEJwbcaKKBls sLmQ== X-Gm-Message-State: APjAAAW7u6976Yk/5q/Q/3RvWUvYNoWgPfWGCLJ4lj6Xam9rsdoeVVjW z+XEmQ86zhPzFdr1e+dkfiw= X-Received: by 2002:ac2:48b6:: with SMTP id u22mr1281287lfg.164.1575446127352; Tue, 03 Dec 2019 23:55:27 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id u2sm2752309lfd.4.2019.12.03.23.55.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 23:55:26 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1icPVV-0003JY-2n; Wed, 04 Dec 2019 08:55:33 +0100 Date: Wed, 4 Dec 2019 08:55:33 +0100 From: Johan Hovold To: Ikjoon Jang Cc: Johan Hovold , 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 Subject: Re: [PATCH v4 2/2] usb: overridable hub bInterval by device node Message-ID: <20191204075533.GI10631@localhost> References: <20191203101552.199339-1-ikjn@chromium.org> <20191203165301.GH10631@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 04, 2019 at 03:04:53PM +0800, Ikjoon Jang wrote: > 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. 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? > > > + 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? > > > + } > > > + > > > /* > > > * Fix up bInterval values outside the legal range. > > > * Use 10 or 8 ms if no proper value can be guessed. Johan