Fixes Hax page fault issue for Yagl driver in windows. 70/279370/1
authorVarinder Pratap <varinder.p@samsung.com>
Mon, 8 Aug 2022 06:10:38 +0000 (11:40 +0530)
committerVarinder Pratap <varinder.p@samsung.com>
Mon, 8 Aug 2022 06:10:50 +0000 (11:40 +0530)
Change-Id: I3654d22ca8343b5918d1ee63e6a6ee676403be25
Signed-off-by: Varinder Pratap <varinder.p@samsung.com>
hw/yagl/yagl_device.c
hw/yagl/yagl_process.h
hw/yagl/yagl_thread.c
hw/yagl/yagl_transport.c
tizen/src/hw/pci/maru_camera_win32.c

index 2af93083ede6e7afdf329225ecc61cc2a8dc5dbe..2d52864a4bb71f56f17caba3b257823330cad8d4 100644 (file)
@@ -199,10 +199,15 @@ static uint64_t yagl_device_read(void *opaque, hwaddr offset,
 static void yagl_device_write(void *opaque, hwaddr offset,
                               uint64_t value, unsigned size)
 {
+    YAGL_LOG_NO_TS;
+
+    YAGL_LOG_FUNC_ENTER(yagl_device_trigger, "%d, %d, %d", offset, value, size);
     YaGLState *s = (YaGLState*)opaque;
     int user_index = (offset / YAGL_REGS_SIZE);
     offset -= user_index * YAGL_REGS_SIZE;
 
+    YAGL_LOG_CRITICAL("yagl_device_write user_index = %d, offset=%d", user_index, offset);
+
     assert(user_index < YAGL_MAX_USERS);
 
     if (user_index >= YAGL_MAX_USERS) {
@@ -310,6 +315,8 @@ static void yagl_device_init(PCIDevice *dev, Error **err)
                           TYPE_YAGL_DEVICE,
                           YAGL_MEM_SIZE);
 
+    pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->iomem);
+
     yagl_handle_gen_init();
 
     egl_driver = yagl_egl_driver_create(dobj->dpy, s->gl_version);
@@ -358,8 +365,6 @@ static void yagl_device_init(PCIDevice *dev, Error **err)
         goto fail;
     }
 
-    pci_register_bar(&s->dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->iomem);
-
     YAGL_LOG_FUNC_EXIT(NULL);
 
     return;
@@ -435,8 +440,9 @@ static void yagl_class_init(ObjectClass *klass, void *data)
     k->exit = yagl_device_exit;
     k->vendor_id = PCI_VENDOR_ID_YAGL;
     k->device_id = PCI_DEVICE_ID_YAGL;
-    k->class_id = PCI_CLASS_OTHERS;
+    k->class_id = PCI_CLASS_DISPLAY_OTHER;
     dc->reset = yagl_device_reset;
+    set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
     device_class_set_props(dc, yagl_properties);
     dc->desc = "YaGL device";
 }
index bbf4568b5847822a83bf92174492a4291d74c794..7d55c0eab09623a4b20177d82ddad2b6e04c15a9 100644 (file)
@@ -55,7 +55,7 @@ struct yagl_process_state
 
     QLIST_HEAD(, yagl_thread_state) threads;
 
-#if defined (CONFIG_KVM) || defined (CONFIG_HAX)
+#if defined (CONFIG_KVM) || defined (CONFIG_HAX) || defined (CONFIG_WHPX)
     target_ulong cr[5];
     uint32_t hflags;
 #endif
index 332628216ef82e4b45f2dd796039f7f8b2d03a57..ca1f98827ad5f7d6302b24facc09a47c60f0df69 100644 (file)
@@ -38,6 +38,7 @@
 #include "hw/vigs/winsys.h"
 #include "sysemu/kvm.h"
 #include "sysemu/hax.h"
+#include "sysemu/whpx.h"
 
 struct yagl_thread_work_item
 {
@@ -51,10 +52,10 @@ struct yagl_thread_work_item
     uint32_t out_arrays_size;
 };
 
-#if defined (CONFIG_KVM) || defined (CONFIG_HAX)
+#if defined (CONFIG_KVM) || defined (CONFIG_HAX) || defined (CONFIG_WHPX)
 static __inline void yagl_cpu_synchronize_state(struct yagl_process_state *ps)
 {
-    if (kvm_enabled() || hax_enabled()) {
+    if (kvm_enabled() || hax_enabled() || whpx_enabled()) {
         CPUX86State *env = current_cpu->env_ptr;
         memcpy(&((CPUX86State *)current_cpu->env_ptr)->cr[0],
                 &ps->cr[0],
index 0ae51d27360ea3fbb79e4e1c2abbb623f0facd86..365d8698f4011374c70aef3e0f54ca3de719f44a 100644 (file)
@@ -149,6 +149,10 @@ uint8_t *yagl_transport_begin(struct yagl_transport *t,
     uint32_t num_out_da, i;
     uint8_t *batch_data, *tmp;
 
+    YAGL_LOG_NO_TS;
+
+    YAGL_LOG_FUNC_ENTER(yagl_transport_begin, NULL);
+
     *fence_seq = yagl_transport_uint32_t_at(t, 1 * 8);
     *batch_size = yagl_transport_uint32_t_at(t, 2 * 8);
     num_out_da = yagl_transport_uint32_t_at(t, 3 * 8);
@@ -166,6 +170,9 @@ uint8_t *yagl_transport_begin(struct yagl_transport *t,
 
     tmp += header_size + YAGL_TRANSPORT_BATCH_HEADER_SIZE + *batch_size;
 
+
+    YAGL_LOG_CRITICAL("yagl_transport_begin - batch_size=%d, out_arrays_size=%d, fence_seq=%d, num_out_da=%d", *batch_size, *out_arrays_size, 
+                              *fence_seq, num_out_da);
     for (i = 0; i < num_out_da; ++i) {
         target_ulong va = yagl_transport_va_at(t,
             YAGL_TRANSPORT_BATCH_HEADER_SIZE + *batch_size + ((2 * i + 0) * 8));
@@ -175,6 +182,8 @@ uint8_t *yagl_transport_begin(struct yagl_transport *t,
         if (!yagl_mem_get(t->ts, va, size, tmp)) {
             yagl_transport_uint32_t_to(t, 0, yagl_call_result_retry);
             g_free(batch_data);
+
+            YAGL_LOG_FUNC_EXIT(NULL);
             return NULL;
         }
 
@@ -188,6 +197,8 @@ uint8_t *yagl_transport_begin(struct yagl_transport *t,
 
     yagl_transport_uint32_t_to(t, 0, yagl_call_result_ok);
 
+    YAGL_LOG_FUNC_EXIT(NULL);
+
     return batch_data;
 }
 
index 210d27d28d0471e3930f38dcc6dd93702e5421e3..0aa2a02625a1d4ad52236234c292ed60f00e7a37 100644 (file)
@@ -32,6 +32,7 @@
 #include "qemu-common.h"
 #include "qemu/cutils.h"
 #include "sysemu/hax.h"
+#include "sysemu/whpx.h"
 #include "maru_camera.h"
 #include "debug_ch.h"
 
@@ -1524,18 +1525,9 @@ static STDMETHODIMP SetFormat(MCBackendWin *backend, uint32_t dwWidth,
                         }
                         /* use minimum FPS(maximum frameinterval)
                            with non-VT system  */
-#ifdef CONFIG_HAX
-                        if (!hax_enabled()) {
-                            pvi->AvgTimePerFrame =
-                                    (REFERENCE_TIME)scc.MaxFrameInterval;
-                        } else {
-                            pvi->AvgTimePerFrame =
-                                (REFERENCE_TIME)MARUCAM_DEFAULT_FRAMEINTERVAL;
-                        }
-#else
                         pvi->AvgTimePerFrame =
                                 (REFERENCE_TIME)scc.MaxFrameInterval;
-#endif
+
                         hr = IAMStreamConfig_SetFormat(pSConfig, pmtConfig);
                         DeleteMediaType(pmtConfig);
                         break;