From: "Longpeng(Mike)" via <qemu-devel@nongnu.org>
To: <pbonzini@redhat.com>, <alex.williamson@redhat.com>,
<mst@redhat.com>, <mtosatti@redhat.com>
Cc: <kvm@vger.kernel.org>, <qemu-devel@nongnu.org>,
<arei.gonglei@huawei.com>, Longpeng <longpeng2@huawei.com>
Subject: [PATCH 1/2] kvm-irqchip: introduce new API to support route change
Date: Sat, 11 Dec 2021 22:27:02 +0800 [thread overview]
Message-ID: <20211211142703.1941-2-longpeng2@huawei.com> (raw)
In-Reply-To: <20211211142703.1941-1-longpeng2@huawei.com>
From: Longpeng <longpeng2@huawei.com>
As suggested by Paolo [1], add the new API to support route changes.
We should invoke kvm_irqchip_begin_route_changes() before changing the
routes, increase the KVMRouteChange.changes if the routes are changed,
and commit the changes at last.
[1] https://lists.gnu.org/archive/html/qemu-devel/2021-11/msg02898.html
Signed-off-by: Longpeng <longpeng2@huawei.com>
---
include/sysemu/kvm.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 7b22aeb6ae..ef143c2da4 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -209,6 +209,11 @@ DECLARE_INSTANCE_CHECKER(KVMState, KVM_STATE,
extern KVMState *kvm_state;
typedef struct Notifier Notifier;
+typedef struct KVMRouteChange {
+ KVMState *s;
+ int changes;
+} KVMRouteChange;
+
/* external API */
bool kvm_has_free_slot(MachineState *ms);
@@ -479,6 +484,20 @@ int kvm_irqchip_add_msi_route(KVMState *s, int vector, PCIDevice *dev);
int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg,
PCIDevice *dev);
void kvm_irqchip_commit_routes(KVMState *s);
+
+static inline KVMRouteChange kvm_irqchip_begin_route_changes(KVMState *s)
+{
+ return (KVMRouteChange) { .s = s, .changes = 0 };
+}
+
+static inline void kvm_irqchip_commit_route_changes(KVMRouteChange *c)
+{
+ if (c->changes) {
+ kvm_irqchip_commit_routes(c->s);
+ c->changes = 0;
+ }
+}
+
void kvm_irqchip_release_virq(KVMState *s, int virq);
int kvm_irqchip_add_adapter_route(KVMState *s, AdapterInfo *adapter);
--
2.23.0
next prev parent reply other threads:[~2021-12-11 14:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-11 14:27 [PATCH 0/2] kvm/msi: do explicit commit when adding msi routes Longpeng(Mike) via
2021-12-11 14:27 ` Longpeng(Mike) via [this message]
2021-12-11 14:27 ` [PATCH 2/2] " Longpeng(Mike) via
2022-01-04 0:48 ` [PATCH 0/2] " longpeng2--- 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=20211211142703.1941-2-longpeng2@huawei.com \
--to=qemu-devel@nongnu.org \
--cc=alex.williamson@redhat.com \
--cc=arei.gonglei@huawei.com \
--cc=kvm@vger.kernel.org \
--cc=longpeng2@huawei.com \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.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 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).