From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3B64606A31A for ; Wed, 2 Dec 2026 12:03:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=NYRztfBc Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xYj3G-0008E8-8J; Wed, 02 Dec 2026 07:03:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xYj3E-0008E0-V8 for qemu-devel@nongnu.org; Wed, 02 Dec 2026 07:03:08 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1xYj3D-0004YK-8s for qemu-devel@nongnu.org; Wed, 02 Dec 2026 07:03:08 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4b467581b98so120482415e9.0 for ; Wed, 02 Dec 2026 04:03:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1796212985; x=1796817785; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Zf6EKzQQe2VAlrcSW8ee8yj0dAuP5r1gUkaoT9x3D1g=; b=NYRztfBcqtz7M+H1kR3m87pw6UCoyhXl7cG3Vkm+WucZEbWHDIRXs2UdWKBxVBwBp0 kMPLN6eg75xYrR53VG+mEhEX1LaAXkKu2RQF5+w7ici7e8JZ9i9BF7euCIpi7zujcJRJ Hvu3I4a2Bvp7ILsJbWWzKeYseeQ6XeO0feMokQKW2+XNxDHLRsaZPpdr95dHoIhrDSoM c6KMb+L0oDibSa0QwS3bF5SYyz9hj1S8/7xvzIF4hSNTkG4v6MJCLtqs0gtiZyUyHiSM 1N1A5o47xM/YvqhGcWRRGokAkzCI4EzWAZKASR79T84hMZmwsWwGSpaGxGdXBcTy8QEh W4Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796212985; x=1796817785; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Zf6EKzQQe2VAlrcSW8ee8yj0dAuP5r1gUkaoT9x3D1g=; b=HJ7KhyvPimlnyfCS347F/WxcqN6a0VHWmB8RGB7QzWZ7sTvtO0v95uvzvXPP4D5MA9 9M50IO2xtQUdSJt+zjijgkC/C43lgowPX1x0FEQt7A4rXYWRPiYljt3rswjH6kAQuYsR f+IVFmOWVeao5fn9/t/zR/8duFZwcEYOBE+mM5qVPoyccQHs0FpWdGWmB7bkkH5JV/OD YmcxElFFRpDV9KTJZDtB2gsfl0erw+H9+Pnhnoby0tfd8em8ctjpCkdspLYjhrmJ0PN/ e70LZdlZ5Y0iTa97jtVRIrNAE5YT8S95DfZ53OvExv4q3TLcKFRJMVye4P/TdJ5kPor8 uscw== X-Gm-Message-State: APuU4Z8OH/8EcaBdOhHIIej3vKv6fhGA7ZWPFtjlFuzZES8MAN7m87lQ a/I8K7e/2b7TGd9JNQfp6IJWQCXHfZAMwFkoHeSWVCLsR2bcwDvuteo7GzQoJ6U2E6Q= X-Gm-Gg: AZFdTZf6DgVNUOA0IJ7Jtnryp4ypB2AsP3yy7/VzOERWYKGEFAkIkjN92njxKh8BORD wNYI4Dd0KWLiIuTJ5foK2NYx++o/nvL9ShTHEn/Wzpoon40WwvqvmsXuJIL10BKuDO38g/bcZvc XSeDoC5cRGV9QmTtlgzP7GL9JNjTjl69aKaaXO9s126des4Ui6vSrjAnLpHWFT/J1XoCY39Z2oA He+fgChcLyL4SUkFALL1LiI45Bz0x1pLCMss2FLvGUlDw/HNWft/aF9MakEOkyKZa3KWKixtABG oNun82sOHsJLPqn5OvBx8oOMzmMVRyq+W/foxJNfFl7OLuQ9JGrpVEt9TgCho7sjYYtstXpEJ+p 3YjoPLTS+tYyEAWgiQ/L/vBnuDPDysKY1fzLkUNrjRSJ2oSO/jme//WsitLwMBd7Pze/T0qnVg7 UhrIG85XJhRkD2m/znkcEytEvXz0IGv8A6qFimOAgPBzZ1in3Jak/zSB9R+EHca38vxGeMa3oqJ feaO+UQstEQNsIHCJuW37non1Jnve55lKTgMQMm3NIogsZg9fCgGWA/i1aqnckCFFdEeqUVme0v oHdkibl38+0Zy03yafUbbn8OlatptRE= X-Received: by 2002:a05:600c:a55:b0:4a1:992f:d0e7 with SMTP id 5b1f17b1804b1-4bb889234a7mr762395495e9.16.1796212985310; Wed, 02 Dec 2026 04:03:05 -0800 (PST) Received: from linaro.org ([2a10:d582:31e:0:c9d9:d338:21ea:5f32]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb8526cbd0sm1450365045e9.0.2026.12.02.04.03.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 04:03:04 -0800 (PST) Date: Wed, 2 Dec 2026 12:03:03 +0000 From: Jim MacArthur To: Gustavo Romero Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" Subject: Re: [PATCH 1/4] hw/pci-bridge: Add pcie_add_dvsec_capability helper Message-ID: References: <20261029-jmac-pcie-rme-extensions-v1-0-212d2409563e@linaro.org> <20261029-jmac-pcie-rme-extensions-v1-1-212d2409563e@linaro.org> <5ypckdele5g7ttn4bojpgipyriirbch2ngoq5bhbafrtfv6ohl@kda4ym255hhq> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5ypckdele5g7ttn4bojpgipyriirbch2ngoq5bhbafrtfv6ohl@kda4ym255hhq> Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=jim.macarthur@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 > > --- > > 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