lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250917200815.GA1872720@bhelgaas>
Date: Wed, 17 Sep 2025 15:08:15 -0500
From: Bjorn Helgaas <helgaas@...nel.org>
To: "Verma, Devendra" <Devendra.Verma@....com>
Cc: "bhelgaas@...gle.com" <bhelgaas@...gle.com>,
	"mani@...nel.org" <mani@...nel.org>,
	"vkoul@...nel.org" <vkoul@...nel.org>,
	"dmaengine@...r.kernel.org" <dmaengine@...r.kernel.org>,
	"linux-pci@...r.kernel.org" <linux-pci@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"Simek, Michal" <michal.simek@....com>
Subject: Re: [PATCH v2 1/2] dmaengine: dw-edma: Add AMD MDB Endpoint Support

On Wed, Sep 17, 2025 at 11:59:09AM +0000, Verma, Devendra wrote:
> > -----Original Message-----
> > From: Bjorn Helgaas <helgaas@...nel.org>
> > Sent: Tuesday, September 16, 2025 20:34
> > To: Verma, Devendra <Devendra.Verma@....com>
> > Cc: bhelgaas@...gle.com; mani@...nel.org; vkoul@...nel.org;
> > dmaengine@...r.kernel.org; linux-pci@...r.kernel.org; linux-
> > kernel@...r.kernel.org; Simek, Michal <michal.simek@....com>
> > Subject: Re: [PATCH v2 1/2] dmaengine: dw-edma: Add AMD MDB Endpoint
> > Support
> >
> > Caution: This message originated from an External Source. Use proper caution
> > when opening attachments, clicking links, or responding.
> >
> >
> > On Tue, Sep 16, 2025 at 04:13:18PM +0530, Devendra K Verma wrote:
> > > AMD MDB PCIe endpoint support. For AMD specific support added the
> > > following
> > >   - AMD supported PCIe Device IDs and Vendor ID (Xilinx).
> > >   - AMD MDB specific driver data
> > >   - AMD MDB specific VSEC capability to retrieve the device DDR
> > >     base address.

> > > -     vsec = pci_find_vsec_capability(pdev, PCI_VENDOR_ID_SYNOPSYS,
> > > -                                     DW_PCIE_VSEC_DMA_ID);
> > > +     /*
> > > +      * Synopsys and AMD (Xilinx) use the same VSEC ID for the purpose
> > > +      * of map, channel counts, etc.
> > > +      */
> > > +     if (vendor != PCI_VENDOR_ID_SYNOPSYS ||
> > > +         vendor != PCI_VENDOR_ID_XILINX)
> > > +             return;
> > > +
> > > +     cap = DW_PCIE_VSEC_DMA_ID;
> > > +     if (vendor == PCI_VENDOR_ID_XILINX)
> > > +             cap = DW_PCIE_XILINX_MDB_VSEC_ID;
> > > +
> > > +     vsec = pci_find_vsec_capability(pdev, vendor, cap);
> >
> > This looks correct, so it's OK as-is.  But it does require more
> > analysis to verify than it would if you did it like this:
> >
> >   vsec = pci_find_vsec_capability(pdev, PCI_VENDOR_ID_SYNOPSYS,
> >                                   DW_PCIE_SYNOPSYS_VSEC_DMA_ID);
> >   if (!vsec) {
> >     vsec = pci_find_vsec_capability(pdev, PCI_VENDOR_ID_XILINX,
> >                                     DW_PCIE_XILINX_VSEC_DMA_ID);
> >     if (!vsec)
> >       return;
> >   }
> >
> > This way it's obvious from the pci_find_vsec_capability() calls
> > themselves (and could potentially be checked by coccinelle, etc)
> > that we're using the Vendor ID and VSEC ID correctly.
> 
> Instead of the above format, a clear assignment to vendor and cap
> would be good enough.  Reason for this is, if a third vendor comes
> and supports the same VSEC=0x6 id with similar capabilities then it
> looks bulky to put another clause as given above. Instead of this a
> cleaner approach would be to have a single
> pci_find_vsec_capability() and clear assignment to vendor and cap
> variables to make it look cleaner. Eg:

> switch (pdev->vendor) {
> case PCI_VENDOR_ID_XILINX:
>         vendor = pdev->vendor;
>         cap = DW_PCIE_XILINX_MDB_VSEC_DMA_ID;
> case PCI_VENDOR_ID_SYNOPSYS:
>         ...
> default:
>         return;
> }
> vsec = pci_find_vsec_capability(pdev, vendor, cap);

OK, that is less clumsy although not as mechanically checkable.

There's not much point in assigning "vendor = pdev->vendor".  You
could just do this:

  switch (pdev->vendor) {
  case PCI_VENDOR_ID_XILINX:
    cap = DW_PCIE_XILINX_MDB_VSEC_DMA_ID;
    break;
  case PCI_VENDOR_ID_SYNOPSYS:
    cap = DW_PCIE_SYNOPSYS_VSEC_DMA_ID;
    break;
  default:
    return;
  }

  pci_find_vsec_capability(pdev, pdev->vendor, cap);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ