Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1594592lqt; Wed, 20 Mar 2024 08:28:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWrtFRQCvPzJzqwpwZMM1pDwo2y2BuOLyFEKlkyZZgXYEOpFtzcRVfVamByaQJvCoMpnRVdnQZuvIMeyAHhp6pKqQodUfwz2+eQnFr+2g== X-Google-Smtp-Source: AGHT+IHjC1/0l2ZXavcEiPMKh1dSwWGv1aRcTm5qwdFY+O2QyOrJny+dM+7N9NqKM72KX6MagdKu X-Received: by 2002:a17:902:a3c4:b0:1dd:78f8:3e1 with SMTP id q4-20020a170902a3c400b001dd78f803e1mr5187062plb.44.1710948489156; Wed, 20 Mar 2024 08:28:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710948489; cv=pass; d=google.com; s=arc-20160816; b=AZtW/kVrIvIZot+n5zWz+LNuga9TCvWIQjuf2QHcxEd1auNp2oiF3+gOAuUzTypEmQ eUTVbemws9YrSUluspV/2XDkrLCpZRQaV9kzPsjeJjl5zrHy1lSM9j/x5/z+L7+fTggv gDYAp0u/tv5d91OFgYfDmogf0qRSts2Sw9/lIIafMGT4a4AlVDd/bHFKp2lxdnLliv9j 9FTLPNRUr7QZ3fhhBN/lYH6J7DetBIBab9lc0tTCx2eH8Xcmqt/EPkMtBMe2ooTLSUdd 5JW8VQtoZFDW7KG3sOqx/4mWe8rxZ6qYLGioVaTNqzd9GddyXxnifmGr90gwArGvvoxp yuNg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=LAuXmYxtnv4Z13tfrPTPny9q2D9yRDHGgVlUHJAfvZw=; fh=fkKoct288JduyRH9sRZSCOE6AyfyZXoRKSn4+5nSeDM=; b=cx7NEwKoIIGdBwVA4j67Z9/DgDEs7lFNZuSqiT8jgolLd96tMhg7O1DW0YzziVXqZi Obd+qwxUhOG4w0ODelz3xHWze/kjTWX78KZv/jDUurs02XoT+mrjH370DITXPORbKf3T Xn7rsmHAkiVLSGqNdC1elt5oJllQu71+J/+tu4gdj8Sxl2e6iLHVllavDt7P12VjPy20 x9A7EShSjJBIqdP6CI1U/cU2SytEgPxMyQ17TGuQ/z4mXXYWvuxhzkicnGfnOQygVUg0 ZEqXum9Jy7aD9AWSgXUXZfY42Ve42RBl4cmw7alll6QsFo0a8r/NP8nSypvuGpLq8W1V XNxw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lx6tJPUY; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-109094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109094-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f4-20020a170902ce8400b001ddcc1543d4si13267404plg.64.2024.03.20.08.28.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 08:28:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109094-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=@quicinc.com header.s=qcppdkim1 header.b=lx6tJPUY; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-109094-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109094-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com 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 0507B284850 for ; Wed, 20 Mar 2024 15:27:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E8D3524AA; Wed, 20 Mar 2024 15:27:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="lx6tJPUY" Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 973D44EB3A; Wed, 20 Mar 2024 15:27:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710948467; cv=none; b=hGvlO1jH6AnwT5aQHmXa0ICt+AoUoRUH6qxXbGatiE+pAB1HUljMv6k0pvNdIMk+5QWrddSyVgessdyqdifIr9FRAdKcjZMqzA1JYPUmrhSAiPApWv86hXWpye5mrKEicuZT3jr34P3ryfBegeU8JJCwzO4ZjkX6vYYfqwtzn94= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710948467; c=relaxed/simple; bh=VvXjFVhDC5UdCnZSDdvqRXiLwR+8ZN3m2Xh2BQnT37Y=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=gNVzDO4uf4888KOs2/J2FKQRYxjqNPPyeDbpYo0rsH1QMIMKmJSkJ3cQsocnUR2RXkJpOEzzoCCkS1bmbG0hENq2lf+wEcVOgZsj8+8WQ1M6Esknitvk1ENI4Sq0Bg6S8N/rSAAlsA0n6m0PzcRNUR5Aw6Ic5M78LIHV4zS5blo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=lx6tJPUY; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42KEk1gS024538; Wed, 20 Mar 2024 15:27:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=LAuXmYxtnv4Z13tfrPTPny9q2D9yRDHGgVlUHJAfvZw=; b=lx 6tJPUYF9sEoKuKLuKEMSd1lEUmRNRmyapeJywNYHG8dM4S+uNVwlzM4EZai7W/o8 LBwTsXYqx7r8PG1O8Z0lQsrHEr+cWGVvmUR3A4F3NDPaagdskWvv4MGR4X5pHEe9 7kmESDVN23z+BQYkp6R+rBXYrXMh9V4VzRVOBYAsWXsTZTPnD5PmN1yic2n7ExAr vsTkv3HFT3hdORUJpFWGz8eQPDlGrWrWCAI0efAv3B3d5TpydbjOQeE+Tw+hBQO3 IlkCmxXBGR2D1d/aPhVztafQcfS07YnNaBFaEmO/2mxBvdxtZpiJGrzrjVcHgUHN w/feNtj5zLBNNLkq63Hw== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wyxq90k7s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Mar 2024 15:27:32 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 42KFRVu8026059 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Mar 2024 15:27:31 GMT Received: from [10.216.53.102] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Wed, 20 Mar 2024 08:27:25 -0700 Message-ID: <83dfe28d-505b-4009-044c-684827a1656d@quicinc.com> Date: Wed, 20 Mar 2024 20:57:20 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 Subject: Re: [PATCH v2] PCI: dwc: Enable runtime pm of the host bridge Content-Language: en-US To: Manivannan Sadhasivam , Bjorn Helgaas CC: "Rafael J. Wysocki" , Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , =?UTF-8?Q?Krzysztof_Wilczy=c5=84ski?= , Rob Herring , Bjorn Helgaas , , , , , , , References: <20240308171248.GA685266@bhelgaas> <20240319111148.GF52500@thinkpad> From: Krishna Chaitanya Chundru In-Reply-To: <20240319111148.GF52500@thinkpad> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: wbtsVke2C90ulOLeApO9PlwAgo3ml6tG X-Proofpoint-GUID: wbtsVke2C90ulOLeApO9PlwAgo3ml6tG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-20_10,2024-03-18_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxlogscore=999 clxscore=1011 priorityscore=1501 impostorscore=0 suspectscore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2403140001 definitions=main-2403200123 On 3/19/2024 4:41 PM, Manivannan Sadhasivam wrote: > 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 > I will these runtime enable inside the pci_host_probe(). - Krishna Chaitanya.