Minor code cleanup and bug fixes to ibbus:
- squelch debug output when a file is closed without a context
- store the control code of IOCTL requests in a local variable to avoid pulling 
them from the I/O stack for each check when dispatching IOCTLs.
- complete unhandled requests that reach the control device instead of ignoring 
them.

Signed-off-by: Fab Tillier <[email protected]>

diff -dwup3 -x *svn* -x *makefile.inc -x *sources -r 
c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\al\kernel\al_dev.c 
.\core\al\kernel\al_dev.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\al\kernel\al_dev.c       
Thu May 31 11:22:15 2012
+++ .\core\al\kernel\al_dev.c   Thu Jul 26 15:31:13 2012
@@ -441,8 +441,7 @@ al_dev_close(
        p_context = (al_dev_open_context_t*)p_io_stack->FileObject->FsContext;
        if( !p_context )
        {
-               AL_PRINT( TRACE_LEVEL_ERROR, AL_DBG_ERROR,
-                       ("Client closed with a null open context .\n") );
+               AL_EXIT( AL_DBG_DEV );
                return CL_SUCCESS;
        }
        if( p_io_stack->FileObject->FsContext2 )
@@ -492,6 +491,8 @@ al_dev_close(
        __destroy_open_context( p_context );
        cl_free( p_context );
 
+    p_io_stack->FileObject->FsContext = NULL;
+
        AL_EXIT( AL_DBG_DEV );
        return CL_SUCCESS;
 }
@@ -569,6 +570,7 @@ al_dev_ioctl(
        size_t                          ret_bytes = 0;
        void                            *p_open_context;
        IO_STACK_LOCATION       *p_io_stack;
+    uint32_t            ctl_code;
 
        AL_ENTER( AL_DBG_DEV );
 
@@ -580,31 +582,47 @@ al_dev_ioctl(
                cl_ioctl_in_size( h_ioctl ), cl_ioctl_in_buf( h_ioctl )) );
 
        /* Process the ioctl command. */
-       if( IS_AL_PROXY_IOCTL(cl_ioctl_ctl_code( h_ioctl )) )
+    ctl_code = cl_ioctl_ctl_code( h_ioctl );
+
+       if( IS_AL_PROXY_IOCTL(ctl_code) )
+    {
                cl_status = proxy_ioctl( h_ioctl, &ret_bytes );
-       else if( IS_VERBS_IOCTL(cl_ioctl_ctl_code( h_ioctl )) )
+    }
+       else if( IS_VERBS_IOCTL(ctl_code) )
+    {
                cl_status = verbs_ioctl( h_ioctl, &ret_bytes );
-       //else if( IS_CM_IOCTL(cl_ioctl_ctl_code( h_ioctl )) )
-       //      cl_status = cm_ioctl( h_ioctl, &ret_bytes );
-       else if( IS_CEP_IOCTL(cl_ioctl_ctl_code( h_ioctl )) )
+    }
+       else if( IS_CEP_IOCTL(ctl_code) )
+    {
                cl_status = cep_ioctl( h_ioctl, &ret_bytes );
-       else if( IS_AL_IOCTL(cl_ioctl_ctl_code( h_ioctl )) )
+    }
+       else if( IS_AL_IOCTL(ctl_code) )
+    {
                cl_status = al_ioctl( h_ioctl, &ret_bytes );
-       else if( IS_SUBNET_IOCTL(cl_ioctl_ctl_code( h_ioctl )) )
+    }
+       else if( IS_SUBNET_IOCTL(ctl_code) )
+    {
                cl_status = subnet_ioctl( h_ioctl, &ret_bytes );
-       else if( IS_IOC_IOCTL(cl_ioctl_ctl_code( h_ioctl )) )
+    }
+       else if( IS_IOC_IOCTL(ctl_code) )
+    {
                cl_status = ioc_ioctl( h_ioctl, &ret_bytes );
-       else if( IS_NDI_IOCTL(cl_ioctl_ctl_code( h_ioctl )) )
+    }
+       else if( IS_NDI_IOCTL(ctl_code) )
+    {
                cl_status = ndi_ioctl( h_ioctl, &ret_bytes );
+    }
        else
+    {
                cl_status = CL_INVALID_REQUEST;
+    }
 
        switch( cl_status )
        {
        case CL_COMPLETED:
                /* Flip the status since the IOCTL was completed. */
                cl_status = CL_SUCCESS;
-               /* Fall through */
+               __fallthrough;
        case CL_PENDING:
                break;
        case CL_INVALID_REQUEST:
diff -dwup3 -x *svn* -x *makefile.inc -x *sources -r 
c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\al\kernel\al_proxy.h 
.\core\al\kernel\al_proxy.h
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\al\kernel\al_proxy.h     
Thu May 31 11:22:15 2012
+++ .\core\al\kernel\al_proxy.h Thu Jul 26 15:31:13 2012
@@ -229,7 +229,7 @@ static VOID __insert_irp(
 }
 
 #ifdef NTDDI_WIN8
-static IO_CSQ_REMOVE_IRP __insert_irp;
+static IO_CSQ_REMOVE_IRP __remove_irp;
 #endif
 
 static VOID __remove_irp(
@@ -402,10 +402,6 @@ cl_status_t subnet_ioctl(
        IN              cl_ioctl_handle_t               h_ioctl,
                OUT     size_t                                  *p_ret_bytes );
 
-cl_status_t cm_ioctl(
-       IN              cl_ioctl_handle_t               h_ioctl,
-               OUT     size_t                                  *p_ret_bytes );
-
 cl_status_t cep_ioctl(
        IN              cl_ioctl_handle_t               h_ioctl,
                OUT     size_t                                  *p_ret_bytes );
diff -dwup3 -x *svn* -x *makefile.inc -x *sources -r 
c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\bus\kernel\bus_driver.c 
.\core\bus\kernel\bus_driver.c
--- c:\dev\openib\ofw\gen1\branches\mlx4_30\trunk\core\bus\kernel\bus_driver.c  
Wed Aug 01 17:24:22 2012
+++ .\core\bus\kernel\bus_driver.c      Thu Jul 26 16:08:33 2012
@@ -939,9 +939,20 @@ bus_drv_close(
        IN                              DEVICE_OBJECT                           
*p_dev_obj,
        IN                              IRP                                     
                *p_irp )
 {
+       NTSTATUS                        status;
+
        UNUSED_PARAM( p_dev_obj );
 
-       p_irp->IoStatus.Status = STATUS_SUCCESS;
+       CL_ASSERT( KeGetCurrentIrql() == PASSIVE_LEVEL );
+
+       /*
+        * Note that we don't acquire the remove and stop lock on close to allow
+        * applications to close the device when the locks are already held.
+        */
+       status = cl_to_ntstatus( al_dev_close( p_irp ) );
+
+       /* Complete the IRP. */
+       p_irp->IoStatus.Status = status;
        p_irp->IoStatus.Information = 0;
        IoCompleteRequest( p_irp, IO_NO_INCREMENT );
 
@@ -990,11 +1001,20 @@ bus_drv_ioctl(
        status = cl_to_ntstatus( al_dev_ioctl( p_irp ) );
        
        /* Only pass down if not handled and not PDO device. */
-       if( status == STATUS_INVALID_DEVICE_REQUEST && p_ext->cl_ext.p_next_do )
+       if( status == STATUS_INVALID_DEVICE_REQUEST )
+    {
+        if( p_ext->cl_ext.p_next_do != NULL )
        {
                IoSkipCurrentIrpStackLocation( p_irp );
                status = IoCallDriver( p_ext->cl_ext.p_next_do, p_irp );
        }
+        else
+        {
+            p_irp->IoStatus.Status = status;
+            p_irp->IoStatus.Information = 0;
+            IoCompleteRequest( p_irp, IO_NO_INCREMENT );
+        }
+    }
 
        /* Release the remove and stop locks. */
        IoReleaseRemoveLock( &p_ext->cl_ext.remove_lock, p_irp );

Attachment: ndv2.25.patch
Description: ndv2.25.patch

_______________________________________________
ofw mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ofw

Reply via email to