From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2B94C74A5B for ; Fri, 17 Mar 2023 21:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=erqjD9ZNDt2Oe33jcnHqDs+9ixKfFIBvPvP6jlR3xzU=; b=dUVYKp6LmFaPm/ wzr5qQ4KPjjhAe6pFc1Et6fUkovETLfXc5OMQyqDjeE2KOx08C1ZuhRP7t8/6kSPOCH3pdKGzcVTA PkUeXy5B9CBhJcdXz5kKDm0KrbeqpHpWr/Pmx3oURJ5Yz4/u86bf98goUwDAh8YR9tZ7g6w/RsOa7 r/fOIove2EBOsuol51Vkj0dHDsj2vkIYkywT8uwtKqUBOmbjnQfgTatG6fIlKphlMcXVJSG/h7DiV /a+vjZJN4MlCEpu1DimTwYmCzoTi5W3yENOjAf6psiOv6dSOThBioFClV+0byU8f+ORAxTMdRQkQv VLtDhw0GcXrTkX7D4Iiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdI4G-003Wus-0s; Fri, 17 Mar 2023 21:56:56 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdI4D-003WuO-1h for linux-arm-kernel@lists.infradead.org; Fri, 17 Mar 2023 21:56:54 +0000 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 7F25660244; Fri, 17 Mar 2023 21:56:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6DC6C433EF; Fri, 17 Mar 2023 21:56:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679090211; bh=RcXRkLZJ0QUiQo2PkgHUJgLw7K4eCtZTz+7xcLtd8gc=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=LQ52gPcq7B7KpQewa8arpjOH/RHGDvWniPMgCTUt08BidUSzn57gVqCgbA/UJfQQw 2noMdjLPJVPIru50MD0BA+8HhW0eI9nnyoNGvJRs7DDOUwHgFjaRwjLzllptVfpR99 00CFMbcc4AWGYT4e6Gq9L5KRkscAryhZFb3yBBejqT1OvdxwTZ6cVBlXWJrOrY3VMc KSTQVL+pLrh1jl1JzsXvmmmdHBKwQvJ/yTtcNznvtoZuRFm4CQ6gZZw9OUqVcHgrp/ PkoTjUF1DLvgg0dk2YqynfsQYOxQfWr69Env2PfEABv9VkP1IKYrMmwrSpzkq3b6x7 5h4SCeHq9s9Vg== Date: Fri, 17 Mar 2023 16:56:50 -0500 From: Bjorn Helgaas To: Frank Li Cc: lorenzo.pieralisi@arm.com, kw@linux.com, Zhiqiang.Hou@nxp.com, bhelgaas@google.com, devicetree@vger.kernel.org, gustavo.pimentel@synopsys.com, leoyang.li@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, minghuan.Lian@nxp.com, mingkai.hu@nxp.com, robh+dt@kernel.org, roy.zang@nxp.com, shawnguo@kernel.org Subject: Re: [PATCH 1/1] PCI: layerscape: Add power management support Message-ID: <20230317215650.GA1973940@bhelgaas> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230317200528.2481154-1-Frank.Li@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230317_145653_661690_1D585225 X-CRM114-Status: GOOD ( 19.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Mar 17, 2023 at 04:05:28PM -0400, Frank Li wrote: > From: Hou Zhiqiang > > Add PME_Turn_Off/PME_TO_Ack handshake sequence, and finally > put the PCIe controller into D3 state after the L2/L3 ready > state transition process completion. Can you please include a sentence or two about what this means for devices below the PCIe controller? Is this guaranteed to be safe for them, i.e., can all PCIe devices tolerate PME_Turn_Off, etc., and resume correctly afterwards? I suspect other drivers will copy this sort of pattern if it is safe and useful. > struct ls_pcie { > struct dw_pcie *pci; > + const struct ls_pcie_drvdata *drvdata; > + void __iomem *pf_base; > + void __iomem *lut_base; > + bool big_endian; > + bool ep_presence; This means "any downstream device present", right? Could be an Endpoint or could be a Switch Upstream Port? I guess it's basically a cache of dw_pcie_link_up() at ls_pcie_host_init()-time. > + bool pm_support; > + struct regmap *scfg; > + int index; > }; > +static void ls1021a_pcie_send_turnoff_msg(struct ls_pcie *pcie) > +{ > + u32 val; > + > + if (!pcie->scfg) { > + dev_dbg(pcie->pci->dev, "SYSCFG is NULL\n"); > + return; > + } > + > + /* Send Turn_off message */ > + regmap_read(pcie->scfg, SCFG_PEXPMWRCR(pcie->index), &val); > + val |= PMXMTTURNOFF; > + regmap_write(pcie->scfg, SCFG_PEXPMWRCR(pcie->index), val); > + > + /* > + * Components with an upstream port must respond to > + * PME_Turn_Off with PME_TO_Ack but we can't check. > + * > + * The standard recommends a 1-10ms timeout after which to > + * proceed anyway as if acks were received. Spec citation please. > + */ > + mdelay(10); > + > + /* Clear Turn_off message */ > + regmap_read(pcie->scfg, SCFG_PEXPMWRCR(pcie->index), &val); > + val &= ~PMXMTTURNOFF; > + regmap_write(pcie->scfg, SCFG_PEXPMWRCR(pcie->index), val); > +} > +static bool ls_pcie_pm_check(struct ls_pcie *pcie) This is used as a boolean ("if (!ls_pcie_pm_check())") so it needs a better name. "Check" doesn't give any hint about what a true or false return value means. Something like "pm_supported" *would* give a hint because "if (!ls_pcie_pm_supported())" is a sensible question to ask. > +{ > + if (!pcie->ep_presence) { > + dev_dbg(pcie->pci->dev, "Endpoint isn't present\n"); > + return false; > + } > + > + if (!pcie->pm_support) > + return false; Why test the negative ("!pcie->pm_support") and then return false? How about: if (pcie->pm_support) return true; return false; or even better, just: return pcie->pm_support; > + return true; > +} _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel