Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3902503pxk; Tue, 29 Sep 2020 09:02:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGCgGRenIzIRHoLglKVLlDgbNF5liaIORiiH6ZiG4AstfI9L2cNGe1/uAGIipyYGoJASbW X-Received: by 2002:a17:906:7d0d:: with SMTP id u13mr4810957ejo.448.1601395335652; Tue, 29 Sep 2020 09:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601395335; cv=none; d=google.com; s=arc-20160816; b=NHJsqM4vJM/GT/2Llp0jF9aBVEm9vZwJfiEP8PVLAgyU/YwQAAy28cdOdNmo1unG+1 jUSHXTloOF3bnKAP7gYPahMVKJ8mspTLrOCeCbkGCcxrI2VQchXoqDz13vWpAABPqF/r 7ndNJW+7JOtYBQz+hcl22N63vjIXRSXePi5DJ3XZO+Q+V29WaC1Oxja3P48tsUYlcEBc Lq6X+xOTrsAa7ihgz+3AppaeandnZuM7Txvd74q3fCqdJoXWO44wuCsHeR3CG6eJGL/O UHVPF/KHqdK/Wnl4nIP/0mDtW9uLUx7HnCizI0VLVgCAd1vof7wWsaOyY9G/f2tpoUiX Q5dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=HtFkHNVC1B0AbpqAP28WPDfk2a1DpG/DdLCCH02/Iss=; b=C1SRkilOlIOhaZUtE4tJaYz0odMqwDN2Osmn/anm47b8W6jxG1fwghqL9RwAha5PFS PWI0AQqDmddLykAelqBvPUSQKZ08xXYuRd4bB2K8N0F+7y8DximOccTB0ahxUJOnX3rz KPTkz6pzBvqBRNCOHv6zipwiBT3Z7opTitjlB76UWYERjY6JeFibu7fDS75EM5HhAXFS AXSI07YVJrtcVGRfaLMjFEiTcd7pUpqE+SrBk+6vHGUMnHFS/EjxADnMxZh61GbmssKF Z8KicEmPCMjy8tj9l+UhtZQfdwZ+SabOlSPlvjQisy9vRBLFLSTkarNGU6HQmrK8LRsS e+iQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f17si3037482edq.587.2020.09.29.09.01.50; Tue, 29 Sep 2020 09:02:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728758AbgI2QAh (ORCPT + 99 others); Tue, 29 Sep 2020 12:00:37 -0400 Received: from netrider.rowland.org ([192.131.102.5]:51239 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1728570AbgI2QAh (ORCPT ); Tue, 29 Sep 2020 12:00:37 -0400 Received: (qmail 175276 invoked by uid 1000); 29 Sep 2020 12:00:36 -0400 Date: Tue, 29 Sep 2020 12:00:36 -0400 From: Alan Stern To: Matthias Kaehlcke Cc: Greg Kroah-Hartman , Rob Herring , Frank Rowand , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Bastien Nocera , Stephen Boyd , Douglas Anderson , Ravi Chandra Sadineni , Krzysztof Kozlowski , devicetree@vger.kernel.org, Peter Chen , "Alexander A. Klimov" , "David S. Miller" , Johan Hovold , Masahiro Yamada , Mauro Carvalho Chehab , Rob Herring Subject: Re: [PATCH v4 2/2] USB: misc: Add onboard_usb_hub driver Message-ID: <20200929160036.GC173077@rowland.harvard.edu> References: <20200928101326.v4.1.I248292623d3d0f6a4f0c5bc58478ca3c0062b49a@changeid> <20200928101326.v4.2.I7c9a1f1d6ced41dd8310e8a03da666a32364e790@changeid> <20200928184759.GB142254@rowland.harvard.edu> <20200929014355.GA1099144@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200929014355.GA1099144@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 28, 2020 at 06:43:55PM -0700, Matthias Kaehlcke wrote: > > Have you tried manually unbinding and rebinding the two drivers a few > > times to make sure they will still work? > > I went through a few dozen bund/unbind cycles for both drivers and things > looked good overall, but then last minute I found that determining whether > wakeup capable devices are connected doesn't always work as (I) expected. > I didn't see this earlier, it seems to be reproduce more easily after > unbinding and rebinding the platform driver. > > During development I already noticed that usb_wakeup_enabled_descendants() > returns a cached value, which was a problem for an earlier version of the > driver. The values are updated by hub_suspend(), my (flawed) assumption > was that the USB driver would always suspend before the platform driver. > This generally seems to be the case on my development platform after boot, > but not necessarily after unbinding and rebinding the driver. Using the > _suspend_late hook instead of _suspend seems to be a reliable workaround. Yes, for unrelated (i.e., not in a parent-child relation) devices, the PM subsystem doesn't guarantee ordering of suspend and resume callbacks. You can enforce the ordering by using device_pm_wait_for_dev(). But the suspend_late approach seems like a better solution in this case. > > I'm a little concerned about all the devm_* stuff in here; does that > > get released when the driver is unbound from the device or when the device > > is unregistered? And if the latter, what happens if you have multiple > > sysfs attribute groups going at the same time? > > The memory gets released when the device is unbound: > > device_release_driver > device_release_driver_internal > __device_release_driver > devres_release_all > > Anyway, if you prefer I can change the driver to use kmalloc/kfree. No, that's fine. I just wasn't sure about this and wanted to check. Alan Stern