Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp616301pxk; Wed, 16 Sep 2020 12:17:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoAKEtlee3xe+C/gjR6nb2Aj5mQlp4S9myP6ZNj7ByJoWxWgZVhHwE4FhZs5lwrKbABCME X-Received: by 2002:a17:906:f92:: with SMTP id q18mr26143855ejj.237.1600283845427; Wed, 16 Sep 2020 12:17:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600283845; cv=none; d=google.com; s=arc-20160816; b=IpoDlUp+L7sZFUVr+3jSCl1qMfAlTH/Jv/Ua0A8AumnyCksYhDeB39ATkSUqe3vV1M z0yeN9iEkprhuyarKCmU5xLQ5XErC+d404AADPsMZhPOsPuNikFd21+nrupk7dwHUkBM ADzzbFjWJIdXUHMMiLJV4PzwrYpY6DS6hMsr2G8FclifQPlqteYZeEdzrpKmtbWWgZBO SK80RcRAR2HrIwYZHRtvapQJRKUZydcgb01Y1eRyqqzb59Cwc9akVF5gmWmbh4YENZWw qfmWVyp0Xz2VQF/+dgNOkskaxaidvfhfVurQUtzqmPQSFupzJp3fukSAmLWZ341AJmwh vc/g== 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 :dkim-signature; bh=Zr61f+8hOqxxTqD74nqUMvtoYbdbG1ifRMQ2x2Wo47k=; b=JHN/kIlFICyahWmP78ezTkNRFu4tp6GZkBMEvfkeeqw26F6LBxURAgfP94Ta5+98p3 i7CB3dDAlc0U+LldDgXUNOhGTsp823X8ETETJXBvxNRxekvSwqL+xps6K6aHwYkvHEHF rZjQ1uHY4UYy9oh/MwRhmNPgFx2Fj6nNGVEcANaVGZ3ZZprgiMfkF2jOk+FoYYDUa8zB HeS8yagyIhnowtYa/vNFdj0VK5PZgkkPfFLStg8EL1QPdReNtm3lAMP5ah9NnIkFArhp e6ZQ4IY2ua+Kyi24DjlATiXGMBIl0+jDlTxhsIMtOfhkE61bhPX6z/ZUuTC/sAkquuCH popg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bbdj+cQG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id b15si4350318ejk.84.2020.09.16.12.17.02; Wed, 16 Sep 2020 12:17:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bbdj+cQG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727837AbgIPTQZ (ORCPT + 99 others); Wed, 16 Sep 2020 15:16:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727354AbgIPTQJ (ORCPT ); Wed, 16 Sep 2020 15:16:09 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86B5FC06174A for ; Wed, 16 Sep 2020 12:16:09 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id k13so3714467plk.3 for ; Wed, 16 Sep 2020 12:16:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Zr61f+8hOqxxTqD74nqUMvtoYbdbG1ifRMQ2x2Wo47k=; b=bbdj+cQGEJp6ctFF99Cjmvo7Dl8c5lDllAMrLmBhmCreCk4CCxJLDuT86uYHIpH65i wGSuUdeoCbqvPWQEyDmbIMuYr11zya+MEL9LgDgHjw9wW2Jrvop4jDknOASk+2eHrGK9 okgBawmmoBqLNMmWc5eB7lENEkN0v3Z7v53pY= 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=Zr61f+8hOqxxTqD74nqUMvtoYbdbG1ifRMQ2x2Wo47k=; b=IIw831QGqjlAGfkUMXwfwlBL6ZdMKlzBTXkTrCsoBMyn9P2Ork8CgDLF2OgKF4Ae0b ZvbINJDgEiAAeE5Pokq3D2B7KKY2q8EXJ3PnhlxL6BBtomES3dmk92lnyN/PgmVxg0KR e6OsvUxj+sb/QA37wjNlp2IceSw2z/bZ8an+2gSHOpb4FYrs8SVk/ym3xdvil2sz+OWe r/woG1Oflrnar1IC5v+U15fuv+6usCEoVT8uFzKnDQZGEINgKDOfEc3+1XJB8W431rHg vDQsfQvfH+70Qef3GegKsGZ3YFrN99Kwoo/nG9cGv1fW1n6Oxk2ICsMjSLIDALSEmGR1 S4xg== X-Gm-Message-State: AOAM532QD0kEl3T577/jLd3T/pmLTBIjywTT2vbDRyr44KfxXfqdWuLd 3KW9a8D6/Fv/48Zou9QVn7iaRw== X-Received: by 2002:a17:90b:208b:: with SMTP id hb11mr5334533pjb.201.1600283768911; Wed, 16 Sep 2020 12:16:08 -0700 (PDT) Received: from localhost ([2620:15c:202:1:f693:9fff:fef4:e70a]) by smtp.gmail.com with ESMTPSA id ih11sm3258735pjb.51.2020.09.16.12.16.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Sep 2020 12:16:08 -0700 (PDT) Date: Wed, 16 Sep 2020 12:16:07 -0700 From: Matthias Kaehlcke To: Peter Chen Cc: Greg Kroah-Hartman , Rob Herring , Frank Rowand , Alan Stern , Krzysztof Kozlowski , Bastien Nocera , Ravi Chandra Sadineni , "linux-usb@vger.kernel.org" , Stephen Boyd , "devicetree@vger.kernel.org" , Douglas Anderson , "linux-kernel@vger.kernel.org" , "Alexander A. Klimov" , Masahiro Yamada Subject: Re: [PATCH 2/2] USB: misc: Add onboard_usb_hub driver Message-ID: <20200916191607.GB3560556@google.com> References: <20200914112716.1.I248292623d3d0f6a4f0c5bc58478ca3c0062b49a@changeid> <20200914112716.2.I7c9a1f1d6ced41dd8310e8a03da666a32364e790@changeid> <20200915025426.GA17450@b29397-desktop> <20200915050207.GF2022397@google.com> <20200915230345.GF2771744@google.com> <20200916081821.GA14376@b29397-desktop> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200916081821.GA14376@b29397-desktop> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peter, On Wed, Sep 16, 2020 at 08:19:07AM +0000, Peter Chen wrote: > On 20-09-15 16:03:45, Matthias Kaehlcke wrote: > > Hi Peter, > > > > On Tue, Sep 15, 2020 at 07:05:38AM +0000, Peter Chen wrote: > > > > > > > > > + hub->cfg.power_off_in_suspend = > > > > of_property_read_bool(dev->of_node, "power-off-in-suspend"); > > > > > > + hub->cfg.wakeup_source = of_property_read_bool(dev->of_node, > > > > > > +"wakeup-source"); > > > > > > > > > > Do you really need these two properties? If the device (and its > > > > > children if existed) has wakeup enabled, you keep power in suspend, > > > > > otherwise, you could close it, any exceptions? > > > > > > > > That would work for my use case, but I'm not sure it's a universally good > > > > configuration. > > > > > > > > I don't have a specific USB device in mind, but you could have a device that > > > > shouldn't lose it's context during suspend or keep operating autonomously (e.g. > > > > a sensor with a large buffer collecting samples). Not sure if something like this > > > > exists in the real though. > > > > > > > > I'm not an expert, but it seems there are USB controllers with wakeup support > > > > which is always enabled. A board with such a controller then couldn't have a > > > > policy to power down the hub regardless of wakeup capable devices being > > > > connected. > > > > > > > > > > Whether or not it is a wakeup_source, it could get through its or its children's > > > /sys/../power/wakeup value, you have already used usb_wakeup_enabled_descendants > > > to know it. > > > > I conceptually agree, but in practice there are some conflicting details: > > > > wakeup for the hubs on my system is by default disabled, yet USB wakeup works > > regardless, so the flag doesn't really provide useful information. I guess we > > could still use it if there is no better way, but it doesn't seem ideal. > > > > Similar for udev->bus->controller, according to sysfs it doesn't even have wakeup > > support. Please let me know if there is a reliable way to check if wakeup is > > enabled on the controller of a device. > > Then, how could your code work, you use usb_wakeup_enabled_descendants > to get if HUB or the descendants under the HUB has wakeup enabled? Doing just that would not allow to switch the hub off when wakeup enabled descendants are connected, which might be desirable in some configurations. > If you use dwc3, you need to enable xhci-plat.c's wakeup entry if your > system needs xHCI connect/disconnect wakeup event. I have one pending > patch to do it: > > https://www.spinics.net/lists/linux-usb/msg199406.html Thanks, my system has indeed a dwc3(-qcom) controller, your patch adds the missing wakeup entry to sysfs. So it seems your patch should solve my problem (sharp timing!), however you mention specifically the 'xHCI connect/disconnect wakeup event', so I wonder if the xHCI wakeup flag isn't applicable to other wakeup events. I know the dwc3-qcom platform device has its own wakeup flag. The driver currently enables wakeup interrupts unconditionally, I sent a patch to change that (https://lore.kernel.org/patchwork/patch/1305894/), however I now wonder if it should evaluate the xHCI wakeup flag instead of its own. Thanks Matthias