summaryrefslogtreecommitdiffstats
path: root/kernel/gsp_rpc_client.c
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-14 06:43:11 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-14 06:43:11 -0400
commit5dd8165f1754e156a0f9fb16c7a6bfa90e99ed60 (patch)
tree7523e29d8044d4d5b6dcd7c1c888a3491137fcd1 /kernel/gsp_rpc_client.c
parent9a7263fce4e3156349a526631805fce66b87fb1b (diff)
downloadopen-iov-5dd8165f1754e156a0f9fb16c7a6bfa90e99ed60.tar.gz
open-iov-5dd8165f1754e156a0f9fb16c7a6bfa90e99ed60.zip
VFIO device registration fix + IOMMUFD callbacks + VFIO ioctl handlers
- Removed IOMMU group addition before vfio_register_emulated_iommu_dev() in nv_vgpu_mdev_create() - Added IOMMUFD callbacks (bind_iommufd, unbind_iommufd, attach_ioas, detach_ioas) using kernel's vfio_iommufd_emulated_* functions - Implemented VFIO ioctl handlers: GET_INFO, GET_REGION_INFO, GET_IRQ_INFO, SET_IRQS, MMAP - Added config space read/write handlers at offset 0x70000000000 - Mmap handler for config space, BAR0 (emulation shadow), BAR1-5 (physical VRAM/registers) - Interrupt handler for VFIO_DEVICE_SET_IRQS (DATA_EVENTFD, DATA_NONE, DATA_BOOL) - Added udev rules for vfio group permissions - Created stack_manager.sh unified tool - Fixed mdev remove crash with deferred cleanup in vfio_device_release callback - Kernel 6.8+ IOMMUFD compatibility - QEMU launches successfully with vGPU passthrough
Diffstat (limited to 'kernel/gsp_rpc_client.c')
-rw-r--r--kernel/gsp_rpc_client.c53
1 files changed, 49 insertions, 4 deletions
diff --git a/kernel/gsp_rpc_client.c b/kernel/gsp_rpc_client.c
index 46d0d50..e91d5f6 100644
--- a/kernel/gsp_rpc_client.c
+++ b/kernel/gsp_rpc_client.c
@@ -132,6 +132,7 @@ struct gsp_client {
wait_queue_head_t resp_wq; /* Response wait queue */
struct workqueue_struct *wq; /* Workqueue for async */
bool initialized;
+ bool emulation_mode; /* Using already-mapped virtual addresses */
};
struct gsp_pending_rpc {
@@ -962,6 +963,47 @@ struct gsp_client *gsp_client_init(struct device *dev, phys_addr_t fw_base, phys
return client;
}
+/* Emulation variant: uses already-mapped virtual addresses */
+struct gsp_client *gsp_client_init_emulation(struct device *dev, void __iomem *fw_base_virt, void __iomem *doorbell_virt)
+{
+ struct gsp_client *client;
+
+ client = kzalloc(sizeof(*client), GFP_KERNEL);
+ if (!client)
+ return ERR_PTR(-ENOMEM);
+
+ client->dev = dev;
+ spin_lock_init(&client->lock);
+ mutex_init(&client->rpc_mutex);
+ INIT_LIST_HEAD(&client->pending_rpcs);
+ init_waitqueue_head(&client->resp_wq);
+ atomic_set(&client->seq_counter, 0);
+
+ /* Use already-mapped virtual addresses directly */
+ client->gsp_fw_base = fw_base_virt;
+ client->rpc_doorbell = doorbell_virt;
+
+ client->wq = alloc_workqueue("gsp_rpc", WQ_UNBOUND, 0);
+ if (!client->wq) {
+ kfree(client);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ /* Init emulation workqueue for scheduling */
+ gsp_sched_wq = alloc_workqueue("gsp_sched", WQ_UNBOUND, 0);
+ if (!gsp_sched_wq) {
+ destroy_workqueue(client->wq);
+ kfree(client);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ client->initialized = true;
+ client->emulation_mode = true;
+ pr_info("GSP RPC client initialized (emulation): fw_base=%p, doorbell=%p\n", fw_base_virt, doorbell_virt);
+
+ return client;
+}
+
void gsp_client_fini(struct gsp_client *client)
{
if (!client)
@@ -975,11 +1017,14 @@ void gsp_client_fini(struct gsp_client *client)
gsp_sched_wq = NULL;
}
- if (client->rpc_doorbell)
- iounmap(client->rpc_doorbell);
+ /* Only iounmap if not in emulation mode (addresses were ioremap'd by us) */
+ if (!client->emulation_mode) {
+ if (client->rpc_doorbell)
+ iounmap(client->rpc_doorbell);
- if (client->gsp_fw_base)
- iounmap(client->gsp_fw_base);
+ if (client->gsp_fw_base)
+ iounmap(client->gsp_fw_base);
+ }
kfree(client);
}