All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim MacArthur <jim.macarthur@linaro.org>
To: Gustavo Romero <gromero@redhat.com>
Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH 1/4] hw/pci-bridge: Add pcie_add_dvsec_capability helper
Date: Wed, 2 Dec 2026 12:03:03 +0000	[thread overview]
Message-ID: <axAI92_e7Nd_otL3@linaro.org> (raw)
In-Reply-To: <5ypckdele5g7ttn4bojpgipyriirbch2ngoq5bhbafrtfv6ohl@kda4ym255hhq>

On Mon, Nov 09, 2026 at 02:08:55AM +0100, Gustavo Romero wrote:
> Hi Jim,
> 
> On Thu, Oct 29, 2026 at 03:05:10PM +0000, Jim MacArthur wrote:
> 
> Please add a commit message to this patch. Even for small changes, a few lines
> of context help reviewers now and anyone reading the history later. For example:
> why a DVSEC helper is needed, what this capability allows, which upcoming patch
> uses it, DVSEC meaning, PCIe spec reference, etc.
> 
> 
> > Signed-off-by: Jim MacArthur <jim.macarthur@linaro.org>
> > ---
> >  hw/pci/pcie.c         | 16 ++++++++++++++++
> >  include/hw/pci/pcie.h |  4 ++++
> >  2 files changed, 20 insertions(+)
> > 
> > diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> > index 42bcb9206d..42c4997b42 100644
> > --- a/hw/pci/pcie.c
> > +++ b/hw/pci/pcie.c
> > @@ -1157,6 +1157,22 @@ void pcie_add_capability(PCIDevice *dev,
> >      memset(dev->cmask + offset, 0xFF, size);
> >  }
> >  
> > +/*
> > + * Add a DVSEC capability. As per pcie_add_capability, the caller must
> > + * ensure (offset, size) does not overlap any other capability or extend
> > + * past the extended configuration space.
> > + */
> > +void pcie_add_dvsec_capability(PCIDevice *device, uint16_t capability_id,
> > +                               uint8_t version, uint32_t offset,
> > +                               uint16_t size_bytes, uint16_t vendor_id,
> > +                               uint8_t dvsec_version, uint16_t dvsec_id)
> > +{
> > +    const uint32_t header1 = size_bytes << 20 | version << 16 | vendor_id;
> 
> Header 1 should have 'dvsec_version' in it, not 'version'. As a side effect
> 'dvsec_version' is left unused here. Also I think it should be 'dvsec_revision',
> not 'dvsec_version'.
> 
> I also think it's better s/size_bytes/dvsec_length/ and
> s/vendor_id/dvsec_vendor_id for consistence.
> 
> It's also better to add range checks for 'dvsec_length' and 'dvsec_revision'
> since their size don't match, respectively, size 16b and 8b, like:
> 
>       assert((dvsec_length & ~0xfff) == 0); 
>       assert((dvsec_revision & ~0xf) == 0);
> 
> 
> > +    pcie_add_capability(device, capability_id, version, offset, size_bytes);
> 
> To me, capability_id and version should actually be hardecoded because a DVSEC
> is by definition PCI_EXT_CAP_ID_DVSEC with Capability Version 1, so:
> 
> pcie_add_capability(dev, PCI_EXT_CAP_ID_DVSEC, 1, offset, dvsec_length);
> 
> I'm looking at PCIe spec rev. 7.0.
> 
> 
> > +    pci_set_long(device->config + offset + 0x4, header1);
> 
> Could we use PCI_DVSEC_HEADER1 here instead of 0x4?
> 
> 
> > +    pci_set_word(device->config + offset + 0x8, dvsec_id);
> 
> Could we use PCI_DVSEC_HEADER2 here instead of 0x8?
> 
> 
> Cheers,
> Gustavo

All good points - thanks for the review!

Jim



  reply	other threads:[~2026-12-02 12:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 15:05 [PATCH 0/4] RME-DA capabilities for PCIe Root Port Jim MacArthur
2026-10-29 15:05 ` [PATCH 1/4] hw/pci-bridge: Add pcie_add_dvsec_capability helper Jim MacArthur
2026-11-04 19:20   ` Jonathan Cameron
2026-11-09  1:08   ` Gustavo Romero
2026-12-02 12:03     ` Jim MacArthur [this message]
2026-10-29 15:05 ` [PATCH 2/4] hw/pci: add IDE + TEE capability to PCIe root port Jim MacArthur
2026-11-04 19:27   ` Jonathan Cameron
2026-11-05 11:48     ` Jim MacArthur
2026-11-12  1:38       ` Jonathan Cameron
2026-11-09  1:11   ` Gustavo Romero
2026-10-29 15:05 ` [PATCH 3/4] hw/pci: add DVSEC RMEDA " Jim MacArthur
2026-11-04 19:29   ` Jonathan Cameron
2026-11-09  1:12   ` Gustavo Romero
2026-10-29 15:05 ` [PATCH 4/4] hw/pci: More comments in pcie.c Jim MacArthur
2026-11-09  1:12   ` Gustavo Romero
2026-11-09  1:13 ` [PATCH 0/4] RME-DA capabilities for PCIe Root Port Gustavo Romero

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=axAI92_e7Nd_otL3@linaro.org \
    --to=jim.macarthur@linaro.org \
    --cc=gromero@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.