Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp577794pxj; Thu, 3 Jun 2021 14:00:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+RhtXMpXWAgobTouu/pHoSdZ7PqIJ3gWdG/JKwTgNG4YOrPOwwEuK4RXaDPF4LKorHw63 X-Received: by 2002:a17:906:848:: with SMTP id f8mr1067125ejd.198.1622754042427; Thu, 03 Jun 2021 14:00:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622754042; cv=none; d=google.com; s=arc-20160816; b=idUC9cYiJ8ERHruJM09hKwlItCSeIeInq5I9rj97mmi2qZW1jRKN9iuhM8UItf/OLh OUH6k1cBsE+hTiYmP8xnG30pDv++LJ3u4VphbJTvULb18CxqfFoLJd4/unukG8ux8wQ2 dfVtD1C1AXeaUhnfYvfa7lJSo7hJ6eYlWgkwXXvcdhnzPWS2HgRN/bdaBJSj3M4ImwNP r0/VqOKFGwND66TWgMLM2hw0QUBNSZCgnN/CId9cqF9fWsh5uIHjJnBKBHyp753U+B0B m62Sujr+wbuPONAuk3rUT8yJNN5jZSaJla/Dnfy9q63qKZ9VGD/LYgO1YqWrm7DJjk6H dkvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=i/htbxHbnMz59QlXs8OOh2dAn8xLE6MHADWSCs0zV8Q=; b=P78jF0gJYAzVWt5YztGZkDbvavNAwOOF2mzMKaoqJcT3ftSdj6ODDcL4tXT4IHTy29 GXHn6IsAJFdFzOwc/B21Ch4WovdinVkD2GYE/S9x1KSya65tHcGehb3EDnp+lh18b55z lnd/d9EgwhadMxwF6xWxPILq8sOfx4W//KIlt3AT1P7j04pfLEd9g4ORMKg2D7H1YBLn I1pLIjUwSFEEPh9epghdaJeysKUz+PZBHLcqKLJRr58fBeyIdGgM4PiedYoXcRwosj4p 23CdLkiV1t8uNXssicT+M20/d9AVRpLFqi8UZlmgB68pOExO02zb29Mn477DSSQQ2oZ3 t9Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HKjMpAIr; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a1si2880441eje.497.2021.06.03.13.59.57; Thu, 03 Jun 2021 14:00:42 -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=@kernel.org header.s=k20201202 header.b=HKjMpAIr; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbhFCVA2 (ORCPT + 99 others); Thu, 3 Jun 2021 17:00:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:45796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229881AbhFCVA1 (ORCPT ); Thu, 3 Jun 2021 17:00:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5FC4D6121D; Thu, 3 Jun 2021 20:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622753922; bh=ZgUmVsDe/y2JJgsw/jVz/sgrfKejv8VUjfp3+iSfR4U=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=HKjMpAIrJAUBto2R9uu3vI7wBwsvSe1z73kIePLZq7GjGn21ladp6L9ustGjlDtNV 33Xrdy04OSBcZMBcVTCL3cs8BHm7ObfyXlJ1uE7byEBNHpSUM5Hb0buLxlzUsOvZHr hWEDPxbDMd6Ik3/eprIYIxWY7UfLm7BZrDDjjExcETb5I/R6lmKiqS7KfISY38pV6k e0y+SpPBuV96iuMYCJmpnvkKZjjSDploQx9ULlp9wP/0RoGkcfZ5gEVxciKDwqRJuS nvkzjdiYXNrK31chC2RgnOV8uaH1HTBAvCfgDhISJOXNCq7DHxB3dJQdVNp1VEJ5OQ QxsUpXuAKh7dg== Date: Thu, 3 Jun 2021 15:58:41 -0500 From: Bjorn Helgaas To: Florian Fainelli Cc: Jim Quinlan , linux-pci@vger.kernel.org, Bjorn Helgaas , Nicolas Saenz Julienne , bcm-kernel-feedback-list@broadcom.com, james.quinlan@broadcom.com, Nicolas Saenz Julienne , Lorenzo Pieralisi , Rob Herring , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" , "moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE" , open list Subject: Re: [PATCH v1 4/4] PCI: brcmstb: add shutdown call to driver Message-ID: <20210603205841.GA2139914@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 03, 2021 at 10:30:37AM -0700, Florian Fainelli wrote: > On 6/3/21 10:23 AM, Bjorn Helgaas wrote: > > On Wed, May 26, 2021 at 10:03:47AM -0700, Florian Fainelli wrote: > >> On 5/25/21 2:18 PM, Bjorn Helgaas wrote: > >>> On Tue, Apr 27, 2021 at 01:51:39PM -0400, Jim Quinlan wrote: > >>>> The shutdown() call is similar to the remove() call except the former does > >>>> not need to invoke pci_{stop,remove}_root_bus(), and besides, errors occur > >>>> if it does. > >>> > >>> This doesn't explain why shutdown() is necessary. "errors occur" > >>> might be a hint, except that AFAICT, many similar drivers do invoke > >>> pci_stop_root_bus() and pci_remove_root_bus() (several of them while > >>> holding pci_lock_rescan_remove()), without implementing .shutdown(). > >> > >> We have to implement .shutdown() in order to meet a certain power budget > >> while the chip is being put into S5 (soft off) state and still support > >> Wake-on-WLAN, for our latest chips this translates into roughly 200mW of > >> power savings at the wall. We could probably add a word or two in a v2 > >> that indicates this is done for power savings. > > > > "Saving power" is a great reason to do this. But we still need to > > connect this to the driver model and the system-level behavior > > somehow. > > > > The pci_driver comment says @shutdown is to "stop idling DMA > > operations" and it hooks into reboot_notifier_list in kernel/sys.c. > > That's incorrect or at least incomplete because reboot_notifier_list > > isn't mentioned at all in kernel/sys.c, and I don't see the connection > > between @shutdown and reboot_notifier_list. > > > > AFAICT, @shutdown is currently used in this path: > > > > kernel_restart_prepare or kernel_shutdown_prepare > > device_shutdown > > dev->bus->shutdown > > pci_device_shutdown # pci_bus_type.shutdown > > drv->shutdown > > > > so we're going to either reboot or halt/power-off the entire system, > > and we're not going to use this device again until we're in a > > brand-new kernel and we re-enumerate the device and re-register the > > driver. > > > > I'm not quite sure how either of those fits into the power-saving > > reason. I guess going to S5 is probably via the kernel_power_off() > > path and that by itself doesn't turn off as much power to the PCIe > > controller as it could? And this new .shutdown() method will get > > called in that path and will turn off more power, but will still leave > > enough for wake-on-LAN to work? And when we *do* wake from S5, > > obviously that means a complete boot with a new kernel. > > Correct, the S5 shutdown is via kernel_power_off() and will turn off all > that we can in the PCIe root complex and its PHY, drop the PCIe link to > the end-point which signals that the end-point can enter its own suspend > logic, too. And yes, when we do wake-up from S5 it means booting a > completely new kernel. S5 is typically implemented in our chips by > keeping just a little bit of logic active to service wake-up events > (infrared remotes, GPIOs, RTC, etc.). Which part of that does this patch change? Is it that the new .shutdown() turns off more power than machine_power_off() does by itself? Bjorn