All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zhijian via <qemu-devel@nongnu.org>
To: Jonathan Cameron <jonathan.cameron@huawei.com>,
	Fan Ni <fan.ni@samsung.com>
Cc: qemu-devel@nongnu.org, Li Zhijian <lizhijian@fujitsu.com>
Subject: [PATCH 1/2] CXL/cxl_type3: add first_dvsec_offset() helper
Date: Tue,  2 Apr 2024 09:46:46 +0800	[thread overview]
Message-ID: <20240402014647.3733839-1-lizhijian@fujitsu.com> (raw)

It helps to figure out where the first dvsec register is located. In
addition, replace offset and size hardcore with existing macros.

Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
---
 hw/mem/cxl_type3.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c
index b0a7e9f11b64..ad2fe7d463fb 100644
--- a/hw/mem/cxl_type3.c
+++ b/hw/mem/cxl_type3.c
@@ -643,6 +643,16 @@ static DOEProtocol doe_cdat_prot[] = {
     { }
 };
 
+static uint16_t first_dvsec_offset(CXLType3Dev *ct3d)
+{
+    uint16_t offset = PCI_CONFIG_SPACE_SIZE;
+
+    if (ct3d->sn != UI64_NULL)
+        offset += PCI_EXT_CAP_DSN_SIZEOF;
+
+    return offset;
+}
+
 static void ct3_realize(PCIDevice *pci_dev, Error **errp)
 {
     ERRP_GUARD();
@@ -663,13 +673,10 @@ static void ct3_realize(PCIDevice *pci_dev, Error **errp)
     pci_config_set_prog_interface(pci_conf, 0x10);
 
     pcie_endpoint_cap_init(pci_dev, 0x80);
-    if (ct3d->sn != UI64_NULL) {
-        pcie_dev_ser_num_init(pci_dev, 0x100, ct3d->sn);
-        cxl_cstate->dvsec_offset = 0x100 + 0x0c;
-    } else {
-        cxl_cstate->dvsec_offset = 0x100;
-    }
+    if (ct3d->sn != UI64_NULL)
+        pcie_dev_ser_num_init(pci_dev, PCI_CONFIG_SPACE_SIZE, ct3d->sn);
 
+    cxl_cstate->dvsec_offset = first_dvsec_offset(ct3d);
     ct3d->cxl_cstate.pdev = pci_dev;
     build_dvsecs(ct3d);
 
-- 
2.29.2



             reply	other threads:[~2024-04-02  1:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-02  1:46 Li Zhijian via [this message]
2024-04-02  1:46 ` [PATCH 2/2] CXL/cxl_type3: reset DVSEC CXL Control in ct3d_reset Li Zhijian via
2024-04-02  9:17   ` Jonathan Cameron via
2024-04-03  3:42     ` Zhijian Li (Fujitsu) via
2024-04-03  9:17       ` Zhijian Li (Fujitsu) via
2024-04-02  4:09 ` [PATCH 1/2] CXL/cxl_type3: add first_dvsec_offset() helper fan
2024-04-02  5:18   ` Zhijian Li (Fujitsu) via
2024-04-02  9:14 ` Jonathan Cameron via

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=20240402014647.3733839-1-lizhijian@fujitsu.com \
    --to=qemu-devel@nongnu.org \
    --cc=fan.ni@samsung.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=lizhijian@fujitsu.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 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.