Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6699978rwl; Wed, 22 Mar 2023 14:22:10 -0700 (PDT) X-Google-Smtp-Source: AK7set9E3yp/UPUMZ4wtUmX3OcnnPo2YcKzByAZxBl2EipBZkVLVckJrpEKyqSDjNqw7tHH0uYsy X-Received: by 2002:a17:906:2a57:b0:930:9f89:65ef with SMTP id k23-20020a1709062a5700b009309f8965efmr8198504eje.11.1679520130565; Wed, 22 Mar 2023 14:22:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679520130; cv=none; d=google.com; s=arc-20160816; b=r7Cg/oF+5hx10dMyv7YUVDe766GkhV98khTK4y86UUq8LaEBP9ZLiu2q4r3HmhuxXX MQWHkVC67ImKXld4jsp5tqgQx/LnjM4zxOtON1TvSYcyrvAO32Zv2pxO9ZkPOjhkpxFP 4vTgwZqik39aP/Zq78kkShUAUtHL4awPlEKcn0cdcOL59ChGU8bbzcQ8GTqN4/Whapoh K2bunzby+OFd8Bvg1N2hNNtVQhTcfI+vShkHlBYjObqb5Ud/zvg6wCaLmvF74b9qQXCV UeZfcNTWdmC6ezddvU4tuLin61771ZGmAe1FoI/u2P3SIAs3SluImbYTJ5F4uPRju2+Z CYAw== 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=8Eiuopmen1r3kA9dS9kbvUTpvJAJDw9x6a97jrkxSS8=; b=WJwb6mGvSYrwJd6+5tGyxwCbb3vMlksKyYaGrVFGVjjmVJlbVIC/4WR7wdSTrUDf1n QW6X/f5wejLtH6qtmyyApn3ad/az+jGfY7RgCv8itmDSUiyibEkV0rYSGU2ynscqFKjL miASHVctgd/pQOQdRXNtxDL4fgsVFuywsTrteGoiHADUQbWHCfiIJ7dLaQKOPpHHP3h2 Nefea//9uxbhQrS2k1pMvzCrMi4wRglyyENtX9EmFRe8hALxxfbapGP9xU0vrq4KPfKU qsQro4s3YIFKFojjfHgsJhPyDqlluJ79pc1mfdxHzaetnCQlviWorLxJTxbfoow6u/jL vPDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RVMGpnos; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc42-20020a1709071c2a00b0093c95dfee2dsi387648ejc.856.2023.03.22.14.21.46; Wed, 22 Mar 2023 14:22:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RVMGpnos; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229487AbjCVVTj (ORCPT + 99 others); Wed, 22 Mar 2023 17:19:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229713AbjCVVTi (ORCPT ); Wed, 22 Mar 2023 17:19:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4054F222FB; Wed, 22 Mar 2023 14:19:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5B13B62199; Wed, 22 Mar 2023 21:19:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78B40C433D2; Wed, 22 Mar 2023 21:19:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679519971; bh=5Lr4+LiAe/vyJjSpCgbGrH8T22xmcBxh9ZpVbFE0NpY=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=RVMGpnosVaaSykQcODe1kChh1yrK8nue3a8krWRC30QZUjZY71F+ENcZPHEVuZnmq lN9loILAp+HBq+s6F1+XfMVbJ09nZFa977xbfUisFB+BysYblpPWft48j1H0mUGqw/ fU4WxhzWOk2HoxCwD5zHi1PdhoKzKehY704Va0T56vbzJUZU36sXoY6L7Ieqxlvh+C MB67XSbpm4k6pOu6nh6JgaMDfwDCWZMejl0L5/mAnHE2i3emSCW/+kLSKadOn1pCYn htkhsd4pj3qa7G5Z0Y/3bSp+HaKcUcPhEvCALwbsh3tUJ1YFgRY+Ex0AxV8A5wv/4l H2O/U1XCwVd/A== Date: Wed, 22 Mar 2023 16:19:29 -0500 From: Bjorn Helgaas To: Frank Li Cc: "bhelgaas@google.com" , Leo Li , dl-linux-imx , "devicetree@vger.kernel.org" , "gustavo.pimentel@synopsys.com" , "kw@linux.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" , "lorenzo.pieralisi@arm.com" , "M.H. Lian" , Mingkai Hu , "robh+dt@kernel.org" , Roy Zang , "shawnguo@kernel.org" , "Z.Q. Hou" Subject: Re: [EXT] Re: [PATCH v2 1/1] PCI: layerscape: Add power management support Message-ID: <20230322211929.GA2493702@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 21, 2023 at 09:39:44PM +0000, Frank Li wrote: > > -----Original Message----- > > From: Bjorn Helgaas > > Sent: Tuesday, March 21, 2023 3:59 PM > > To: Frank Li > > Cc: bhelgaas@google.com; Leo Li ; dl-linux-imx > imx@nxp.com>; devicetree@vger.kernel.org; > > gustavo.pimentel@synopsys.com; kw@linux.com; linux-arm- > > kernel@lists.infradead.org; linux-kernel@vger.kernel.org; linux- > > pci@vger.kernel.org; lorenzo.pieralisi@arm.com; M.H. Lian > > ; Mingkai Hu ; > > robh+dt@kernel.org; Roy Zang ; > > shawnguo@kernel.org; Z.Q. Hou > > Subject: [EXT] Re: [PATCH v2 1/1] PCI: layerscape: Add power management > > support > > > > Caution: EXT Email > > > > On Tue, Mar 21, 2023 at 12:02:20PM -0400, Frank Li wrote: > > > From: Hou Zhiqiang > > > > > > Add PME_Turn_Off/PME_TO_Ack handshake sequence to PCIe devices, > > such as > > > NVME or wifi module, and finally put the PCIe controller into D3 state > > > after the L2/L3 ready state transition process completion. > > > > > > However, it's important to note that not all devices may be able to > > > tolerate the PME_Turn_Off command. In general, fixed PCIe devices > > > connected to Layerscape, such as NXP wifi devices, are able to handle > > > this command. > > > > I know this paragraph is here because I asked whether all PCIe devices > > could tolerate PME_Turn_Off. I don't know much about that level of > > the protocol, but it does look to me like PME_Turn_Off is required, > > e.g., PCIe r6.0, sec 5.3.3.2.1, 5.3.3.4. > > > > So I'm not sure this paragraph adds anything useful. If the spec > > requires it, this paragraph is like saying "it's important to note > > that some PCIe devices may not follow the spec," which is pointless. > > > > This functionality results in any downstream devices being put in > > D3cold, right? I think that *would* be worth mentioning. There are a > > few cases where we try to avoid putting devices in D3cold, e.g., > > no_d3cold, and I suspect this functionality would put them in D3cold > > regardless of no_d3cold. Those are corner cases that you would > > probably never see on your platform, so a brief mention here is > > probably enough. > > > > > +static void ls_pcie_set_dstate(struct ls_pcie *pcie, u32 dstate) > > > +{ > > > + struct dw_pcie *pci = pcie->pci; > > > + u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_PM); > > > + u32 val; > > > + > > > + val = dw_pcie_readw_dbi(pci, offset + PCI_PM_CTRL); > > > + val &= ~PCI_PM_CTRL_STATE_MASK; > > > + val |= dstate; > > > + dw_pcie_writew_dbi(pci, offset + PCI_PM_CTRL, val); > > > > Is this a power management register for the *Root Port*, i.e., as > > defined by PCIe r6.0 sec 7.5.2? > > > > Or is it a similar register for the *Root Complex* as a whole that is > > defined by a Layerscape or DesignWare spec and coincidentally uses the > > same Capability ID and control register layout as the PCIe one? > > I think it is root port. Does linux framework can do that for it > automatically? Or need call pci_set_power_state here instead of > write register directly? Well, maybe, the linux framework might already put Root Ports in D3 if the right conditions are satisfied. I don't understand all of them, but you can start at pci_dev_check_d3cold() and look at its users and instrument things to see what actually happens. But it might be a problem if that has to be synchronized and done in the right order with respect to the RC things you do here, because I don't think there's a hook for the PCI core to call your driver to do the RC stuff. Bjorn