From: yakui.zhao@intel.com (Zhao Yakui)
Subject: [RFC PATCH 12/15] drivers/acrn: add driver-specific IRQ handle to dispatch IO_REQ request
Date: Fri, 16 Aug 2019 10:25:53 +0800 [thread overview]
Message-ID: <1565922356-4488-13-git-send-email-yakui.zhao@intel.com> (raw)
In-Reply-To: <1565922356-4488-1-git-send-email-yakui.zhao@intel.com>
After ACRN hypervisor captures the io_request(mmio, IO, PCI access) from
guest OS, it will send the IRQ interrupt to SOS system.
The HYPERVISOR_CALLBACK_VECTOR ISR handler will be executed and it
needs to call the driver-specific ISR handler to dispatch emulated
io_request.
After the emulation of ioreq request is finished, the ACRN hypervisor
is notified and then can resume the execution of guest OS.
Co-developed-by: Jason Chen CJ <jason.cj.chen at intel.com>
Signed-off-by: Jason Chen CJ <jason.cj.chen at intel.com>
Co-developed-by: Mingqiang Chi <mingqiang.chi at intel.com>
Signed-off-by: Mingqiang Chi <mingqiang.chi at intel.com>
Co-developed-by: Liu Shuo <shuo.a.liu at intel.com>
Signed-off-by: Liu Shuo <shuo.a.liu at intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao at intel.com>
---
drivers/staging/acrn/acrn_dev.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/drivers/staging/acrn/acrn_dev.c b/drivers/staging/acrn/acrn_dev.c
index 28258fb..93f45e3 100644
--- a/drivers/staging/acrn/acrn_dev.c
+++ b/drivers/staging/acrn/acrn_dev.c
@@ -18,6 +18,7 @@
#include <linux/kdev_t.h>
#include <linux/kernel.h>
#include <linux/init.h>
+#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/mm.h>
#include <linux/module.h>
@@ -41,6 +42,7 @@ static int acrn_hsm_inited;
static int major;
static struct class *acrn_class;
static struct device *acrn_device;
+static struct tasklet_struct acrn_io_req_tasklet;
static
int acrn_dev_open(struct inode *inodep, struct file *filep)
@@ -416,6 +418,16 @@ long acrn_dev_ioctl(struct file *filep,
break;
}
case IC_CLEAR_VM_IOREQ: {
+ /*
+ * we need to flush the current pending ioreq dispatch
+ * tasklet and finish it before clearing all ioreq of this VM.
+ * With tasklet_kill, there still be a very rare race which
+ * might lost one ioreq tasklet for other VMs. So arm one after
+ * the clearing. It's harmless.
+ */
+ tasklet_schedule(&acrn_io_req_tasklet);
+ tasklet_kill(&acrn_io_req_tasklet);
+ tasklet_schedule(&acrn_io_req_tasklet);
acrn_ioreq_clear_request(vm);
break;
}
@@ -449,6 +461,28 @@ static int acrn_dev_release(struct inode *inodep, struct file *filep)
return 0;
}
+static void io_req_tasklet(unsigned long data)
+{
+ struct acrn_vm *vm;
+ /* This is already in tasklet. Use read_lock for list_lock */
+
+ read_lock(&acrn_vm_list_lock);
+ list_for_each_entry(vm, &acrn_vm_list, list) {
+ if (!vm || !vm->req_buf)
+ break;
+
+ get_vm(vm);
+ acrn_ioreq_distribute_request(vm);
+ put_vm(vm);
+ }
+ read_unlock(&acrn_vm_list_lock);
+}
+
+static void acrn_intr_handler(void)
+{
+ tasklet_schedule(&acrn_io_req_tasklet);
+}
+
static const struct file_operations fops = {
.open = acrn_dev_open,
.release = acrn_dev_release,
@@ -462,6 +496,7 @@ static const struct file_operations fops = {
static int __init acrn_init(void)
{
+ unsigned long flag;
struct api_version *api_version;
acrn_hsm_inited = 0;
if (x86_hyper_type != X86_HYPER_ACRN)
@@ -518,6 +553,10 @@ static int __init acrn_init(void)
return PTR_ERR(acrn_device);
}
+ tasklet_init(&acrn_io_req_tasklet, io_req_tasklet, 0);
+ local_irq_save(flag);
+ acrn_setup_intr_irq(acrn_intr_handler);
+ local_irq_restore(flag);
acrn_ioreq_driver_init();
pr_info("acrn: ACRN Hypervisor service module initialized\n");
acrn_hsm_inited = 1;
@@ -529,6 +568,8 @@ static void __exit acrn_exit(void)
if (!acrn_hsm_inited)
return;
+ tasklet_kill(&acrn_io_req_tasklet);
+ acrn_remove_intr_irq();
device_destroy(acrn_class, MKDEV(major, 0));
class_unregister(acrn_class);
class_destroy(acrn_class);
--
2.7.4
next prev parent reply other threads:[~2019-08-16 2:25 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-16 2:25 [RFC PATCH 00/15] acrn: add the ACRN driver module Zhao Yakui
2019-08-16 2:25 ` [RFC PATCH 01/15] x86/acrn: Report X2APIC for ACRN guest Zhao Yakui
2019-08-16 2:25 ` [RFC PATCH 02/15] x86/acrn: Add two APIs to add/remove driver-specific upcall ISR handler Zhao Yakui
2019-08-16 2:25 ` [RFC PATCH 03/15] x86/acrn: Add hypercall for ACRN guest Zhao Yakui
2019-08-16 2:25 ` [RFC PATCH 04/15] drivers/acrn: add the basic framework of acrn char device driver Zhao Yakui
2019-08-16 7:05 ` Greg KH
2019-08-19 4:02 ` Zhao, Yakui
2019-08-19 5:26 ` Greg KH
2019-08-16 11:28 ` Dan Carpenter
2019-08-16 2:25 ` [RFC PATCH 05/15] drivers/acrn: add driver-specific hypercall for ACRN_HSM Zhao Yakui
2019-08-16 2:25 ` [RFC PATCH 06/15] drivers/acrn: add the support of querying ACRN api version Zhao Yakui
2019-08-16 2:25 ` [RFC PATCH 07/15] drivers/acrn: add acrn vm/vcpu management for ACRN_HSM char device Zhao Yakui
2019-08-16 2:25 ` [RFC PATCH 08/15] drivers/acrn: add VM memory management for ACRN " Zhao Yakui
2019-08-16 12:58 ` Dan Carpenter
2019-08-19 5:32 ` Zhao, Yakui
2019-08-19 7:39 ` Dan Carpenter
2019-08-19 7:46 ` Borislav Petkov
2019-08-20 2:25 ` Zhao, Yakui
2019-08-16 2:25 ` [RFC PATCH 09/15] drivers/acrn: add passthrough device support Zhao Yakui
2019-08-16 13:05 ` Dan Carpenter
2019-09-02 0:18 ` Zhao, Yakui
2019-08-16 2:25 ` [RFC PATCH 10/15] drivers/acrn: add interrupt injection support Zhao Yakui
2019-08-16 13:12 ` Dan Carpenter
2019-08-19 4:59 ` Zhao, Yakui
2019-08-16 2:25 ` [RFC PATCH 11/15] drivers/acrn: add the support of handling emulated ioreq Zhao Yakui
2019-08-16 13:39 ` Dan Carpenter
2019-08-19 4:54 ` Zhao, Yakui
2019-08-16 2:25 ` Zhao Yakui [this message]
2019-08-16 2:25 ` [RFC PATCH 13/15] drivers/acrn: add service to obtain Power data transition Zhao Yakui
2019-08-16 2:25 ` [RFC PATCH 14/15] drivers/acrn: add the support of irqfd and eventfd Zhao Yakui
2019-08-16 2:25 ` [RFC PATCH 15/15] drivers/acrn: add the support of offline SOS cpu Zhao Yakui
2019-08-19 10:34 ` Dan Carpenter
2019-08-20 2:23 ` Zhao, Yakui
2019-08-16 6:39 ` [RFC PATCH 00/15] acrn: add the ACRN driver module Borislav Petkov
2019-08-16 7:03 ` Greg KH
2019-08-19 2:39 ` Zhao, Yakui
2019-08-19 5:25 ` Greg KH
2019-08-19 1:44 ` Zhao, Yakui
2019-08-19 5:25 ` Greg KH
2019-08-19 5:39 ` Zhao, Yakui
2019-08-19 6:18 ` Borislav Petkov
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=1565922356-4488-13-git-send-email-yakui.zhao@intel.com \
--to=yakui.zhao@intel.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).