Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp791790lqt; Tue, 19 Mar 2024 04:12:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUoi+1b5cJbUcOSMLs8KaFxTjFykBqupE+/OpUV2RpjoB8m5UoajPR6PwSj3El1AVeJpKbMnUK4LPCyBppHNW5LyAjJiq67kL+6Fx3wUg== X-Google-Smtp-Source: AGHT+IHH97YbST2l9DWFDAhVfGdhPed5cxak5caI1obH3NzOsvZ7oSy/hOkAMhxF6gkA+pnkK6xG X-Received: by 2002:a17:90a:1fcd:b0:29c:152f:85eb with SMTP id z13-20020a17090a1fcd00b0029c152f85ebmr1972053pjz.28.1710846726944; Tue, 19 Mar 2024 04:12:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710846726; cv=pass; d=google.com; s=arc-20160816; b=bGhW22sJ/Ud7qOrW6rDd5BMJlDoJ+aeuZpM+mn5MSGhJ1KjlfZ4Hg/v13YSjCP64z/ kelK3KF75nn5sUfCceHH2zrNeE60uqBGSBxVl6N5nGo3tadvhk/QCTBlktcvqbGetTZ+ MbPJ/fiIZbg9fbyIHFsSPdcJEKQIYCNG0At1KUIgT4F0dPcxmrw4jS0Ppi0CzyLevI8j kx/U9VJvUaoMuWcgQH2NUvLvlNQDdK1frVLjdyNrtlHgDeLPF+ObeAosrjaLeuwnZkn7 zfRgonVz0c2v8ZYwAfK9YgQeoN09raoeQRV0yPfEMebRkxxdVpEF2XxtAlIvWwsaCUxO hNDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OpV7V2XsbZLlejqNfMsqdQB5QkQ7j91cgGmJ1H2MAjQ=; fh=9cio4ZGgE8crYrSdbHXrTgPxe0Q8AUHoBCpa8iokFbI=; b=XzhvtEe6kLUUThyjRJmHjpf+GYPrHX22XGtm2hA+eNB9jGftck86acETXMlIXpMHrS Vdxu7fhz9smzXGyXaHHGp8hj9ngJoCa9LhyhoBkt0bTcRmdR3a50Ii/zVf0TeWXL//On 250xR/tJb+v728GtboNVUArzxnMNjHEI/6PIvDHRjYvcHER77dc6x517yjf/HHz916bs nk0MGCwYFVyHt3Zbuf8uWtPvYWHqY2XpH4lfokTt5WjNBb6lNW/jjeHM1NMKm6j6W3fa uRyPqBCm92pY2GpC40cugJ7GTtX+jxBUvERPQFURYQMWTHfyu4dtzAcfBOJzKRIxpkg1 qRkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rLek48J+; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-107443-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107443-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h14-20020a17090acf0e00b0029de042625csi9902710pju.9.2024.03.19.04.12.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 04:12:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-107443-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rLek48J+; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-107443-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107443-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9BC23282813 for ; Tue, 19 Mar 2024 11:12:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60E6B7E593; Tue, 19 Mar 2024 11:11:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rLek48J+" Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1CE87E571 for ; Tue, 19 Mar 2024 11:11:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710846717; cv=none; b=VAqHJmXmVWcwRCftwyRAop0cAz9GlANEFh/EuirE5MnBS/sLpv/2q9Kvyzbif/6LiUENMXpIJYh3nl3sa2BYA9oLEuu5iFwdMtV8OMCXcCS99YTMLHkvxfISvRCEzaQfEh93iuYylbfuXKqvkm0ImHCleC2ORAcOFG5K7Jy4d54= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710846717; c=relaxed/simple; bh=5JmHxvmDPWbQTYeXB1OgMxbSaPC2ut8uFstyW5S3N7I=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VXbz7raWeL41hPcmXCEo1F0OSYZbuJt2ngf178DD6PhDuZjhXrVpFQx0xEH8XWGNEDZ7tmDwEfM2BQQc/QTm0rybAegyjufu7EV6vItXhaYp9lPujBweQvdaqdOXTQIw4Us1/M075Dr9758g/CmQQWoyvqd9wmHS8Dow3iZnRGI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=rLek48J+; arc=none smtp.client-ip=209.85.214.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1dffa5e3f2dso16452505ad.2 for ; Tue, 19 Mar 2024 04:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710846715; x=1711451515; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=OpV7V2XsbZLlejqNfMsqdQB5QkQ7j91cgGmJ1H2MAjQ=; b=rLek48J+tSnE7lyPk+xSOo/rhK3j4XjxxwYhDYD1YOaoxMb9IGjx6qXC4vjRElFOdY IQQWE8B9XgSurDSwxiPuROdjOGtEB67nlfThg7ke8bEZb+P7Cu3fNOsXv2K53GKBTTnu JOYnvdB69sWRl9DBQdDaNzdRgO8jxbZfhZwYzwg5o15HjOWfYZvtpF6QTcfEikgW+boY sSTzG4dcxyVljoUL1boiSm3v2HwgDUcpdZoupVZq1AeEnBOQhLpdsc7lELLV9+ln45yo 2746r+9DqjvVALHMxy8Cg0YYVMAjcLZGXReiY8bJhiehOUZqz6DObCYmFweAV7OmkEkZ ImmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710846715; x=1711451515; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=OpV7V2XsbZLlejqNfMsqdQB5QkQ7j91cgGmJ1H2MAjQ=; b=ia1iQzqgHS6DaYjOP/EL0ZWHkfmAxGPN460EY5ODnmMfrMyl0BHHlNzDZ+0vjVyH4y ulgsQ2YgInFMEYrz1eA1WspIcKYiR2Aas5FL07aVdVFTzENGGgk+Lc5/Nes6e5haEPIT O2OWdBVRsNWxrCjOe8dNUbEyccn/ew5BQ99FLpVQo7eaSlgdLpAbQZnX/LO2HyJUrV6q Me/J090jHMykpLfvA2tUqITa98rA39sBHgx9UVPzoso+/ftZggJQ0NTZoISc9nJn2Gwz 2kW/j42RB44couYXX9yqh0OJySj7Zns4I0QWZ0FBgsoKz7x0RBQ7nMibxKjgZ5gArMYv Vbhg== X-Forwarded-Encrypted: i=1; AJvYcCWcFSO2C6WmIqj6BAUtaIx3fzQH61sJaNteDv0V5vwFcXc37Kc/en6s0TxZ1XTq3w9xcmsE+KJSCMhG15lXvo3+rwzYDJkOusRyRkaW X-Gm-Message-State: AOJu0YwZJhZ7sYU1xfNxYAY32WSE97SrPmxPugV61lJBwdXoPCKS41Co SFVUmwg4rIculfGawXTpUT11blIXpGG4MmU7sXQzQRxRKeTaY0FEY2lyDk2HtA== X-Received: by 2002:a17:903:244c:b0:1dd:2bc8:a56c with SMTP id l12-20020a170903244c00b001dd2bc8a56cmr2626047pls.7.1710846714985; Tue, 19 Mar 2024 04:11:54 -0700 (PDT) Received: from thinkpad ([120.138.12.244]) by smtp.gmail.com with ESMTPSA id o1-20020a170902d4c100b001dd8d7d4a5csm4884876plg.90.2024.03.19.04.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 04:11:54 -0700 (PDT) Date: Tue, 19 Mar 2024 16:41:48 +0530 From: Manivannan Sadhasivam To: Bjorn Helgaas Cc: Krishna Chaitanya Chundru , "Rafael J. Wysocki" , Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, quic_vbadigan@quicinc.com, quic_ramkri@quicinc.com, quic_nitegupt@quicinc.com, quic_skananth@quicinc.com, quic_parass@quicinc.com Subject: Re: [PATCH v2] PCI: dwc: Enable runtime pm of the host bridge Message-ID: <20240319111148.GF52500@thinkpad> References: <20240308171248.GA685266@bhelgaas> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240308171248.GA685266@bhelgaas> On Fri, Mar 08, 2024 at 11:12:48AM -0600, Bjorn Helgaas wrote: > On Fri, Mar 08, 2024 at 08:38:52AM +0530, Krishna Chaitanya Chundru wrote: > > On 3/8/2024 3:25 AM, Bjorn Helgaas wrote: > > > [+to Rafael, sorry, another runtime PM question, beginning of thread: > > > https://lore.kernel.org/r/20240305-runtime_pm_enable-v2-1-a849b74091d1@quicinc.com] > > > > > > On Thu, Mar 07, 2024 at 07:28:54AM +0530, Krishna Chaitanya Chundru wrote: > > > > On 3/6/2024 1:27 AM, Bjorn Helgaas wrote: > > > > > On Tue, Mar 05, 2024 at 03:19:01PM +0530, Krishna chaitanya chundru wrote: > > > > > > The Controller driver is the parent device of the PCIe host bridge, > > > > > > PCI-PCI bridge and PCIe endpoint as shown below. > > > > > > > > > > > > PCIe controller(Top level parent & parent of host bridge) > > > > > > | > > > > > > v > > > > > > PCIe Host bridge(Parent of PCI-PCI bridge) > > > > > > | > > > > > > v > > > > > > PCI-PCI bridge(Parent of endpoint driver) > > > > > > | > > > > > > v > > > > > > PCIe endpoint driver > > > > > > > > > > > > Since runtime PM is disabled for host bridge, the state of the child > > > > > > devices under the host bridge is not taken into account by PM framework > > > > > > for the top level parent, PCIe controller. So PM framework, allows > > > > > > the controller driver to enter runtime PM irrespective of the state > > > > > > of the devices under the host bridge. > > > > > > > > > > IIUC this says that we runtime suspend the controller even though > > > > > runtime PM is disabled for the host bridge? I have a hard time > > > > > parsing this; can you cite a function that does this or some relevant > > > > > documentation about how this part of runtime PM works? > > > > > > > > > Generally controller should go to runtime suspend when endpoint client > > > > drivers and pci-pci host bridge drivers goes to runtime suspend as the > > > > controller driver is the parent, but we are observing controller driver > > > > goes to runtime suspend even when client drivers and PCI-PCI bridge are > > > > in active state. > > > > > > It surprises me that a device could be suspended while children are > > > active. A PCI-PCI bridge must be in D0 for any devices below it to be > > > active. The controller is a platform device, not a PCI device, but I > > > am similarly surprised that we would suspend it when children are > > > active, which makes me think we didn't set the hierarchy up correctly. > > > > > > It doesn't seem like we should need to enable runtime PM for a parent > > > to keep it from being suspended when children are active. > > > > Here we are not enabling runtime PM of the controller device, we are > > enabling runtime PM for the bridge device which is maintained by the > > PCIe framework. The bridge device is the parent of the PCI-PCI > > bridge and child of the controller device. As the bridge device's > > runtime PM is not enabled the PM framework is ignoring the child's > > runtime status. > > OK, it's the host bridge, not the controller. > > I'm still surprised that the PM framework will runtime suspend a > device when child devices are active. > There is a catch here. Even though the child devices are funtionally active, PM framework will only consider their runtime_pm state, which is initially set to 'disabled' for all devices. It is upto the device drivers to enable it when required. Here is the initial runtime PM status of each device post boot: Controller device -> disabled initially but enabled by pcie-qcom.c Host bridge -> disabled initially PCIe bridge -> disabled initially but conditionally enabled by portdrv.c PCIe devices -> disabled initially but enabled by respective drivers like WLAN Now, when the controller device goes to runtime suspend, PM framework will check the runtime PM state of the child device (host bridge) and will find it to be disabled. So it will allow the parent (controller device) to go to runtime suspend. Only if the child device's state was 'active' it will prevent the parent to get suspended. But you may wonder if this is ideal? IMO NO. But we cannot blame the PM framework here. The responsibility is within the device drivers to handle the PM state based on the usecase. Ideally, the host bridge driver should've handled runtime PM state during the probe time. Otherwise, PM framework wouldn't know when would be the best time to suspend the devices. > And further confused about managing the host bridge runtime PM in a > controller driver. Which other callers of pci_alloc_host_bridge() or > devm_pci_alloc_host_bridge() will need similar changes? > This scenario applies to all host bridges. So I think we should enable it inside pci_host_probe(). - Mani -- மணிவண்ணன் சதாசிவம்