Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/cmd.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/cmd.c	(revision 8301)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/cmd.c	(revision 8302)
@@ -1591,7 +1591,8 @@
             goto err_thread;
         }
 
-        spin_lock_init(&priv->mfunc.master.vep_config_lock);
+        spin_lock_init(&priv->mfunc.master.vep_config_lock);			
+#pragma prefast(suppress:28197, "The WI is deleted either at bad flow in this function, mlx4_multi_func_cleanup or mlx_remove_one")
         priv->mfunc.master.vep_config_work = IoAllocateWorkItem(dev->pdev->p_self_do);
         if (priv->mfunc.master.vep_config_work == NULL) {
             MLX4_PRINT(TRACE_LEVEL_ERROR, MLX4_DBG_DRV,("%s: Failed to allocate VEP config work iteam. Insufficient resources \n", dev->pdev->name));
@@ -1698,9 +1699,14 @@
 {
     struct mlx4_priv *priv = mlx4_priv(dev);
     int i, port;
+
+    IoFreeWorkItem(priv->mfunc.master.vep_config_work);
+    priv->mfunc.master.vep_config_work = NULL;
     
     // resource tracker works only for PPF
     if (mlx4_is_master(dev)) {
+        stop_working_thread(&priv->mfunc.master.slave_event_thread);
+        stop_working_thread(&priv->mfunc.master.comm_channel_thread);
         mlx4_free_resource_tracker(dev);
         for (i = 0; i < (int)dev->num_slaves; i++) {
             for (port = 1; port <= MLX4_MAX_PORTS; port++)
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/eq.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/eq.c	(revision 8301)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/eq.c	(revision 8302)
@@ -113,6 +113,9 @@
 }
 
 /* master command processing */
+#ifdef NTDDI_WIN8
+KSTART_ROUTINE mlx4_gen_slave_eqe;
+#endif
 void mlx4_gen_slave_eqe(void* ctx)
 {
 	struct mlx4_priv *priv = (struct mlx4_priv*) ctx;
@@ -262,11 +265,12 @@
 	KeSetEvent(&g.surprise_removal_event, 0, FALSE);
 }
 
-static void
-mlx4_dev_remove_wi(
+static IO_WORKITEM_ROUTINE mlx4_dev_remove_wi;
+static VOID mlx4_dev_remove_wi(
 	IN				DEVICE_OBJECT*				p_dev_obj,
-	IN				struct mlx4_dev 			*dev )
+	IN				PVOID						context)
 {
+	struct mlx4_dev *dev = (struct mlx4_dev *) context;
 	struct mlx4_priv *priv = mlx4_priv(dev);
 	
 	UNUSED_PARAM(p_dev_obj);
@@ -289,10 +293,13 @@
 // NOTE: The mlx4_update_vep_config doesn't call for SRIOV therefore 16 bits are 
 //		 enough for all the functions
 //
+
+static IO_WORKITEM_ROUTINE mlx4_update_vep_config;
 static void mlx4_update_vep_config(
-	DEVICE_OBJECT* p_dev_obj,
-	struct mlx4_dev* dev )
+	IN				DEVICE_OBJECT*				p_dev_obj,
+	IN				PVOID						context)
 {
+	struct mlx4_dev *dev = (struct mlx4_dev *) context;
 	struct mlx4_priv *priv = mlx4_priv(dev);		
 	struct mlx4_mfunc_master_ctx *master = &priv->mfunc.master;
 	struct mlx4_vep_cfg* vep_cfg;
@@ -905,6 +912,9 @@
 	return (BOOLEAN)work;
 }
 
+#ifdef NTDDI_WIN8
+static KSERVICE_ROUTINE mlx4_interrupt;
+#endif
 static BOOLEAN mlx4_interrupt(
 	IN struct _KINTERRUPT *Interrupt,
 	IN PVOID ServiceContext
@@ -955,6 +965,9 @@
 	return fRes;
 }
 
+#ifdef NTDDI_WIN8
+static KDEFERRED_ROUTINE mlx4_dpc_msix;
+#endif
 static void mlx4_dpc_msix( PRKDPC dpc, 
 	PVOID ctx, PVOID arg1, PVOID arg2 )
 {
@@ -981,6 +994,9 @@
 
 #if 1//WORKAROUND_POLL_EQ
 
+#ifdef NTDDI_WIN8
+KSYNCHRONIZE_ROUTINE IsrSynchronizeRoutine;
+#endif
 BOOLEAN
 IsrSynchronizeRoutine(
 	IN PVOID  SynchronizeContext
@@ -993,7 +1009,9 @@
 	return TRUE;
 }
 
-
+#ifdef NTDDI_WIN8
+KSTART_ROUTINE eq_polling_thread;
+#endif
 VOID eq_polling_thread(void *ctx) 
 {
 #define POLLING_INTERVAL_MS	50
@@ -1067,7 +1085,9 @@
 
 #endif
 
-
+#ifdef NTDDI_WIN8
+KMESSAGE_SERVICE_ROUTINE mlx4_msi_x_interrupt;
+#endif
 BOOLEAN
 mlx4_msi_x_interrupt (
 	IN PKINTERRUPT	Interrupt,
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/fw.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/fw.c	(revision 8301)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/fw.c	(revision 8302)
@@ -1708,10 +1708,11 @@
 
 
 void mlx4_opreq_action(
-	DEVICE_OBJECT*		p_dev_obj,
-	struct mlx4_dev 	*dev 
+	IN DEVICE_OBJECT*		p_dev_obj,
+	IN PVOID				context
 	)
 {
+	struct mlx4_dev *dev = (struct mlx4_dev *)context;
 	struct mlx4_priv *priv = mlx4_priv(dev); 
 	int num_tasks = atomic_read(&priv->opreq_count);
 	struct mlx4_cmd_mailbox *mailbox;
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/fw.h
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/fw.h	(revision 8301)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/fw.h	(revision 8302)
@@ -199,7 +199,6 @@
 int mlx4_QUERY_FUNC(struct mlx4_dev *dev, int func, u8 *pf_num);
 int mlx4_update_uplink_arbiter(struct mlx4_dev *dev, int port);
 int mlx4_set_vep_maps(struct mlx4_dev *dev);
-void mlx4_opreq_action(DEVICE_OBJECT* p_dev_obj, struct mlx4_dev *dev);
+IO_WORKITEM_ROUTINE mlx4_opreq_action; 
 
-
 #endif /* MLX4_FW_H */
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/mlx4.h
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/mlx4.h	(revision 8301)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/mlx4.h	(revision 8302)
@@ -790,9 +790,13 @@
 			  struct mlx4_profile *request,
 			  struct mlx4_dev_cap *dev_cap,
 			  struct mlx4_init_hca_param *init_hca);
-
+#ifdef NTDDI_WIN8
+KSTART_ROUTINE mlx4_master_comm_channel;
+KSTART_ROUTINE mlx4_gen_slave_eqe;
+#else
 void mlx4_master_comm_channel(void* ctx);
 void mlx4_gen_slave_eqe(void* ctx);
+#endif
 
 int mlx4_cmd_init(struct mlx4_dev *dev);
 void mlx4_cmd_cleanup(struct mlx4_dev *dev);
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/catas.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/catas.c	(revision 8301)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/net/catas.c	(revision 8302)
@@ -132,13 +132,15 @@
                   ("  buf[%02x]: %08x\n",i , swab32(readl(priv->catas_err.map + i))));
 }
 
-static void
+static IO_WORKITEM_ROUTINE catas_reset_wi;
+static VOID
 catas_reset_wi(
 	IN				DEVICE_OBJECT*				p_dev_obj,
-	IN				struct mlx4_dev *			dev )
+	IN				PVOID						context)
 {
 	NTSTATUS status;
 	long do_reset;
+	struct mlx4_dev * dev = (struct mlx4_dev *) context;
 	UNUSED_PARAM(p_dev_obj);
 
 	dump_err_buf(dev);
@@ -183,7 +185,9 @@
 		spin_unlock_dpc(&catas_lock);
 	}
 }
-
+#ifdef NTDDI_WIN8
+static KDEFERRED_ROUTINE timer_dpc;
+#endif
 static void  timer_dpc(
 	IN struct _KDPC  *Dpc,
 	IN PVOID  DeferredContext,
@@ -380,11 +384,14 @@
 	return err;
 }
 
-static void
+
+static IO_WORKITEM_ROUTINE card_reset_wi;
+static VOID
 card_reset_wi(
-	IN				DEVICE_OBJECT*				p_dev_obj,
-	IN				struct ib_event_handler *	event_handler )
+	IN				PDEVICE_OBJECT				p_dev_obj,
+    IN 				PVOID 						context)
 {
+	struct ib_event_handler *	event_handler = (struct ib_event_handler *) context;
 	struct ib_device *ibdev = event_handler->device;
 
 	UNUSED_PARAM(p_dev_obj);
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/core/cache.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/core/cache.c	(revision 8301)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/core/cache.c	(revision 8302)
@@ -329,10 +329,7 @@
 	ib_cache_update(work->device, work->port_num);
 }
 
-#ifdef NTDDI_WIN8
 static IO_WORKITEM_ROUTINE ib_work_item;
-#endif
-
 static void ib_work_item (
 	IN PDEVICE_OBJECT  DeviceObject,
 	IN PVOID  Context 
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/drv/drv.h
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/drv/drv.h	(revision 8301)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/drv/drv.h	(revision 8302)
@@ -151,23 +151,34 @@
 // drv.c
 //
 extern "C"
+DRIVER_INITIALIZE DriverEntry;
+extern "C"
 NTSTATUS
 DriverEntry(
 	IN PDRIVER_OBJECT DriverObject,
 	IN PUNICODE_STRING RegistryPath
 	);
 
+#ifdef NTDDI_WIN8
+EVT_WDF_DRIVER_UNLOAD EvtDriverUnload;
+#endif
 void
 EvtDriverUnload(
 	IN		WDFDRIVER  Driver
 	);
-	
+
+#ifdef NTDDI_WIN8
+EVT_WDF_DRIVER_DEVICE_ADD EvtDriverDeviceAdd;
+#endif
 NTSTATUS
 EvtDriverDeviceAdd(
 	IN WDFDRIVER        Driver,
 	IN PWDFDEVICE_INIT  DeviceInit
 	);
 
+#ifdef NTDDI_WIN8
+EVT_WDF_DEVICE_PREPARE_HARDWARE EvtPrepareHardware;
+#endif
 NTSTATUS
 EvtPrepareHardware(
 	IN WDFDEVICE  Device,
@@ -175,18 +186,27 @@
 	IN WDFCMRESLIST  ResourcesTranslated
 	);
 
+#ifdef NTDDI_WIN8
+EVT_WDF_DEVICE_RELEASE_HARDWARE EvtReleaseHardware;
+#endif
 NTSTATUS
 EvtReleaseHardware(
 	IN WDFDEVICE  Device,
 	IN WDFCMRESLIST  ResourcesTranslated
 	);
 
+#ifdef NTDDI_WIN8
+EVT_WDF_DEVICE_D0_EXIT EvtDeviceD0Exit;
+#endif
 NTSTATUS
 EvtDeviceD0Exit(
 	IN WDFDEVICE  Device,
 	IN WDF_POWER_DEVICE_STATE  TargetState
 	);
 
+#ifdef NTDDI_WIN8
+EVT_WDF_DEVICE_D0_ENTRY EvtDeviceD0Entry;
+#endif
 NTSTATUS
 EvtDeviceD0Entry(
 	IN WDFDEVICE  Device,
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/drv/pdo.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/drv/pdo.c	(revision 8301)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/drv/pdo.c	(revision 8302)
@@ -74,7 +74,9 @@
 		return STATUS_UNSUCCESSFUL;
 	}
 }
-
+#ifdef NTDDI_WIN8
+EVT_WDF_DEVICE_PROCESS_QUERY_INTERFACE_REQUEST EvtDeviceProcessQueryInterfaceRequest;
+#endif
 NTSTATUS
 EvtDeviceProcessQueryInterfaceRequest(
 	IN WDFDEVICE  Device,
@@ -359,7 +361,6 @@
 
 	RtlInitUnicodeString(&compatIdGeneral, CompatibleIds);
 	RtlInitUnicodeString(&compatId, HardwareIds);
-	PAGED_CODE();
 
 	//
 	// Allocate a WDFDEVICE_INIT structure and set the properties
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/drv/drv.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/drv/drv.c	(revision 8301)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/drv/drv.c	(revision 8302)
@@ -113,7 +113,6 @@
 	return Ticks.QuadPart * g_time_increment / 10000; // 10,000 moves from 100ns to ms
 }
 
-
 NTSTATUS
 __create_child(
 	__in WDFDEVICE	Device,
@@ -142,7 +141,6 @@
 	PPDO_DEVICE_DATA	p_pdo;
 	PFDO_DEVICE_DATA	p_fdo;
 
-	PAGED_CODE ();
 	MLX4_ENTER(MLX4_DBG_DRV);
 
 	//
@@ -859,7 +857,9 @@
 	}
 
 }
-
+#ifdef NTDDI_WIN8
+EVT_WDF_DEVICE_USAGE_NOTIFICATION EvtDeviceUsageNotification;
+#endif
 VOID
 EvtDeviceUsageNotification (
 	IN WDFDEVICE  Device,
Index: B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/drv/wmi.c
===================================================================
--- B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/drv/wmi.c	(revision 8301)
+++ B:/users/xalex/PREFAST_TRUNK_3_0_0/hw/mlx4/kernel/bus/drv/wmi.c	(revision 8302)
@@ -47,8 +47,6 @@
 	NTSTATUS status;
 	DECLARE_CONST_UNICODE_STRING(busRsrcName, BUSRESOURCENAME);
 
-	PAGED_CODE();
-
 	//
 	// Register WMI classes.
 	// First specify the resource name which contain the binary mof resource.
@@ -120,8 +118,6 @@
 {
 	PFDO_DEVICE_DATA fdoData;
 
-	PAGED_CODE();
-
 	fdoData = FdoGetData(WdfWmiInstanceGetDevice(WmiInstance));
 
 	switch(DataItemId)
@@ -176,8 +172,6 @@
 
 	UNREFERENCED_PARAMETER(InBufferSize);
 
-	PAGED_CODE();
-
 	fdoData = FdoGetData(WdfWmiInstanceGetDevice(WmiInstance));
 
 	//
@@ -225,8 +219,6 @@
 
 	UNREFERENCED_PARAMETER(OutBufferSize);
 
-	PAGED_CODE();
-
 	fdoData = FdoGetData(WdfWmiInstanceGetDevice(WmiInstance));
 
 	*BufferUsed = sizeof (BUS_WMI_STD_DATA);

