[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6789275458945_1be6092949c@iweiny-mobl.notmuch>
Date: Thu, 16 Jan 2025 09:35:48 -0600
From: Ira Weiny <ira.weiny@...el.com>
To: "Bowman, Terry" <terry.bowman@....com>, Ira Weiny <ira.weiny@...el.com>,
<linux-cxl@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-pci@...r.kernel.org>, <nifan.cxl@...il.com>, <dave@...olabs.net>,
<jonathan.cameron@...wei.com>, <dave.jiang@...el.com>,
<alison.schofield@...el.com>, <vishal.l.verma@...el.com>,
<dan.j.williams@...el.com>, <bhelgaas@...gle.com>, <mahesh@...ux.ibm.com>,
<oohall@...il.com>, <Benjamin.Cheatham@....com>, <rrichter@....com>,
<nathan.fontenot@....com>, <Smita.KoralahalliChannabasappa@....com>,
<lukas@...ner.de>, <ming.li@...omail.com>,
<PradeepVineshReddy.Kodamati@....com>, <alucerop@....com>
Subject: Re: [PATCH v5 03/16] CXL/PCI: Introduce PCIe helper functions
pcie_is_cxl() and pcie_is_cxl_port()
Bowman, Terry wrote:
>
>
>
> On 1/14/2025 5:33 PM, Ira Weiny wrote:
> > Bowman, Terry wrote:
> >>
> >>
> >> On 1/13/2025 5:49 PM, Ira Weiny wrote:
> >>> Terry Bowman wrote:
[snip]
> >>>> +bool pcie_is_cxl_port(struct pci_dev *dev)
> >>>> +{
> >>>> + if ((pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) &&
> >>>> + (pci_pcie_type(dev) != PCI_EXP_TYPE_UPSTREAM) &&
> >>>> + (pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM))
> >>>> + return false;
> >>>> +
> >>>> + return cxl_port_dvsec(dev);
> >>> Returning bool from a function which returns u16 is odd and I don't think
> >>> it should be coded this way. I don't think it is wrong right now but this
> >>> really ought to code the pcie_is_cxl() here and leave cxl_port_dvsec()
> >>> alone. Calling cxl_port_dvsec(), checking for if the dvsec exists, and
> >>> returning bool.
> >> Hi Ira,
> >>
> >> Thanks for reviewing. Is this what you are looking for here:
> >>
> >> +bool pcie_is_cxl_port(struct pci_dev *dev)
> >> +{
> >> + return (cxl_port_dvsec(dev) > 0);
> > With the type checks, yes that is more clear.
> >
> > Ira
> >
> > [snip]
> Since sending the above I made update to be:
>
> static u16 cxl_port_dvsec(struct pci_dev *dev)
> {
> return pci_find_dvsec_capability(dev, PCI_VENDOR_ID_CXL,
> PCI_DVSEC_CXL_PORT);
> }
>
> inline bool pcie_is_cxl(struct pci_dev *pci_dev)
> {
> return pci_dev->is_cxl;
> }
>
> bool pcie_is_cxl_port(struct pci_dev *pci_dev)
> {
> if (!pcie_is_cxl(pci_dev))
> return false;
>
> return (cxl_port_dvsec(pci_dev) > 0);
> }
>
> I can change if you see anything is needed.
Looks good thanks!
Ira
[snip]
Powered by blists - more mailing lists