qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: robin@streamhpc.com
To: qemu-devel@nongnu.org
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
	Robin Voetter <robin@streamhpc.com>
Subject: [PATCH 1/1] pcie: Allow generic PCIE root port to enable atomic completion
Date: Thu, 20 Apr 2023 17:38:40 +0200	[thread overview]
Message-ID: <20230420153839.167418-2-robin@streamhpc.com> (raw)
In-Reply-To: <20230420153839.167418-1-robin@streamhpc.com>

From: Robin Voetter <robin@streamhpc.com>

Adds an experimental option to the pcie-root-port to make it report
support for the PCIe atomic completion capabilities.  This can now be
enabled by setting the x-atomic-completion option on the pcie-root-port
device.  Defaults to disabled for now.  For example:

    -device pcie-root-port,x-atomic-completion=true,id=pcie.1

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Signed-off-by: Robin Voetter <robin@streamhpc.com>
---
 hw/pci-bridge/gen_pcie_root_port.c | 2 ++
 hw/pci/pcie.c                      | 6 ++++++
 include/hw/pci/pcie_port.h         | 3 +++
 3 files changed, 11 insertions(+)

diff --git a/hw/pci-bridge/gen_pcie_root_port.c b/hw/pci-bridge/gen_pcie_root_port.c
index 1ce4e7beba..097eaecbed 100644
--- a/hw/pci-bridge/gen_pcie_root_port.c
+++ b/hw/pci-bridge/gen_pcie_root_port.c
@@ -145,6 +145,8 @@ static Property gen_rp_props[] = {
                                 speed, PCIE_LINK_SPEED_16),
     DEFINE_PROP_PCIE_LINK_WIDTH("x-width", PCIESlot,
                                 width, PCIE_LINK_WIDTH_32),
+    DEFINE_PROP_BOOL("x-atomic-completion", PCIESlot,
+                     atomic_completion, false),
     DEFINE_PROP_END_OF_LIST()
 };
 
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index b8c24cf45f..5dd61e3cdb 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -663,6 +663,12 @@ void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s)
 
     qbus_set_hotplug_handler(BUS(pci_bridge_get_sec_bus(PCI_BRIDGE(dev))),
                              OBJECT(dev));
+
+    if (s->atomic_completion) {
+        /* PCIe requires setting both comp32 and comp64 if either is supported */
+        pci_set_long(dev->config + dev->exp.exp_cap + PCI_EXP_DEVCAP2,
+                     PCI_EXP_DEVCAP2_ATOMIC_COMP32 | PCI_EXP_DEVCAP2_ATOMIC_COMP64);
+    }
 }
 
 void pcie_cap_slot_reset(PCIDevice *dev)
diff --git a/include/hw/pci/pcie_port.h b/include/hw/pci/pcie_port.h
index 90e6cf45b8..5e85657bb0 100644
--- a/include/hw/pci/pcie_port.h
+++ b/include/hw/pci/pcie_port.h
@@ -68,6 +68,9 @@ struct PCIESlot {
     /* broken ACPI hotplug compat knob to preserve 6.1 ABI intact */
     bool        hide_native_hotplug_cap;
 
+    /* Enables PCIE Atomic completion on pcie_root_port */
+    bool atomic_completion;
+
     QLIST_ENTRY(PCIESlot) next;
 };
 
-- 
2.39.2



  reply	other threads:[~2023-04-20 15:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-20 15:38 [PATCH 0/1] pcie: Allow atomic completion on PCIE root port robin
2023-04-20 15:38 ` robin [this message]
2023-04-21  8:22 ` Michael S. Tsirkin
2023-04-21 16:06   ` Robin Voetter
2023-05-18 20:03     ` Michael S. Tsirkin
2023-05-18 22:13       ` Alex Williamson

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=20230420153839.167418-2-robin@streamhpc.com \
    --to=robin@streamhpc.com \
    --cc=marcel.apfelbaum@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).