mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank Li <frank.li@nxp.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: "lorenzo.pieralisi@arm.com" <lorenzo.pieralisi@arm.com>,
	"kw@linux.com" <kw@linux.com>, "Z.Q. Hou" <zhiqiang.hou@nxp.com>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"gustavo.pimentel@synopsys.com" <gustavo.pimentel@synopsys.com>,
	Leo Li <leoyang.li@nxp.com>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"M.H. Lian" <minghuan.lian@nxp.com>,
	Mingkai Hu <mingkai.hu@nxp.com>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	Roy Zang <roy.zang@nxp.com>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>
Subject: RE: [EXT] Re: [PATCH 1/1] PCI: layerscape: Add power management support
Date: Sat, 18 Mar 2023 01:15:18 +0000	[thread overview]
Message-ID: <AM6PR04MB4838980A1243C5ECDDDF454F88829@AM6PR04MB4838.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <20230317215650.GA1973940@bhelgaas>

> 
> Caution: EXT Email
> 
> On Fri, Mar 17, 2023 at 04:05:28PM -0400, Frank Li wrote:
> > From: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
> >
> > 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?

We can't guarantee all PCIe devices tolerate PME_Turn_off etc. We just
follow PCI Spec and test some available devices to make sure our implement
 is correct.

Anyways, it was still better than nothing.  

> 
> 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.

Should be an Endpoint.  Most of our user case is that connect pcie
wifi module.   

> 
> > +     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;
> > +}

      reply	other threads:[~2023-03-18  1:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17 20:05 Frank Li
2023-03-17 21:56 ` Bjorn Helgaas
2023-03-18  1:15   ` Frank Li [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM6PR04MB4838980A1243C5ECDDDF454F88829@AM6PR04MB4838.eurprd04.prod.outlook.com \
    --to=frank.li@nxp.com \
    --cc=bhelgaas@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gustavo.pimentel@synopsys.com \
    --cc=helgaas@kernel.org \
    --cc=kw@linux.com \
    --cc=leoyang.li@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=minghuan.lian@nxp.com \
    --cc=mingkai.hu@nxp.com \
    --cc=robh+dt@kernel.org \
    --cc=roy.zang@nxp.com \
    --cc=shawnguo@kernel.org \
    --cc=zhiqiang.hou@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®