[MTHCA] fixed erroneous rewriting of the PCI bus interface
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 5 Apr 2006 07:34:54 +0000 (07:34 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 5 Apr 2006 07:34:54 +0000 (07:34 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@285 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mthca/kernel/hca_driver.c

index 762fce4..3373c15 100644 (file)
@@ -109,11 +109,6 @@ fw_access_pciconf (
                IN              ULONG                                                   offset,\r
                IN              ULONG POINTER_ALIGNMENT                 length );\r
 \r
-static NTSTATUS\r
-fw_get_pci_bus_interface(\r
-       IN              DEVICE_OBJECT                           *p_dev_obj,\r
-       OUT             BUS_INTERFACE_STANDARD          *p_BusInterface );\r
-\r
 static NTSTATUS\r
 fw_flash_write_data (\r
                IN              BUS_INTERFACE_STANDARD                  *p_BusInterface,\r
@@ -388,55 +383,6 @@ fw_access_pciconf (
        return status;\r
 }\r
 \r
-static NTSTATUS\r
-fw_get_pci_bus_interface(\r
-       IN              DEVICE_OBJECT                           *p_dev_obj,\r
-       OUT             BUS_INTERFACE_STANDARD          *p_BusInterface )\r
-{\r
-       KEVENT event;\r
-       NTSTATUS status;\r
-       PIRP p_irp;\r
-       IO_STATUS_BLOCK ioStatus;\r
-       PIO_STACK_LOCATION p_irpStack;\r
-       PDEVICE_OBJECT p_target_obj;\r
-\r
-       KeInitializeEvent( &event, NotificationEvent, FALSE );\r
-\r
-       p_target_obj = IoGetAttachedDeviceReference( p_dev_obj );\r
-\r
-       p_irp = IoBuildSynchronousFsdRequest( IRP_MJ_PNP,\r
-                                                                               p_target_obj,\r
-                                                                               NULL,\r
-                                                                               0,\r
-                                                                               NULL,\r
-                                                                               &event,\r
-                                                                               &ioStatus );\r
-       if (p_irp == NULL) {\r
-               status = STATUS_INSUFFICIENT_RESOURCES;\r
-               goto End;\r
-       }\r
-       p_irpStack = IoGetNextIrpStackLocation( p_irp );\r
-       p_irpStack->MinorFunction = IRP_MN_QUERY_INTERFACE;\r
-       p_irpStack->Parameters.QueryInterface.InterfaceType = (LPGUID) &GUID_BUS_INTERFACE_STANDARD;\r
-       p_irpStack->Parameters.QueryInterface.Size = sizeof(BUS_INTERFACE_STANDARD);\r
-       p_irpStack->Parameters.QueryInterface.Version = 1;\r
-       p_irpStack->Parameters.QueryInterface.Interface = (PINTERFACE) p_BusInterface;\r
-       p_irpStack->Parameters.QueryInterface.InterfaceSpecificData = NULL;\r
-\r
-       p_irp->IoStatus.Status = STATUS_NOT_SUPPORTED;\r
-       \r
-       status = IoCallDriver( p_target_obj, p_irp );\r
-\r
-       if ( status == STATUS_PENDING )\r
-       {\r
-               KeWaitForSingleObject( &event, Executive, KernelMode, FALSE, NULL );\r
-               status = ioStatus.Status;\r
-       }\r
-End:\r
-       // Done with reference\r
-       ObDereferenceObject( p_target_obj );\r
-       return status;\r
-}\r
 \r
 static NTSTATUS\r
 __map_crspace(\r
@@ -542,6 +488,20 @@ __unmap_crspace(
        HCA_EXIT( HCA_DBG_PNP );\r
 }\r
 \r
+\r
+static void\r
+__open_fw_access(\r
+       IN                              struct ib_ucontext*                     p_context,\r
+       IN                              PBUS_INTERFACE_STANDARD         p_bus_interface )\r
+{\r
+       if( !p_context->fw_if_open )\r
+       {\r
+               p_bus_interface->InterfaceReference( p_bus_interface->Context );\r
+               p_context->fw_if_open = TRUE;\r
+       }\r
+}\r
+\r
+\r
 static void \r
 __close_fw_access(\r
        IN              struct ib_ucontext *    p_context,\r
@@ -554,6 +514,7 @@ __close_fw_access(
        }\r
 }\r
 \r
+\r
 void\r
 unmap_crspace_for_all( struct ib_ucontext *p_context )\r
 {\r
@@ -580,7 +541,7 @@ fw_access_ctrl(
        IN      OUT                     ci_umv_buf_t                            *p_umv_buf )\r
 {\r
        DEVICE_OBJECT                           *p_dev_obj;\r
-       PBUS_INTERFACE_STANDARD    p_bus_interface;\r
+       PBUS_INTERFACE_STANDARD         p_bus_interface;\r
        NTSTATUS                                        status = STATUS_SUCCESS;\r
        PVOID                                           p_data;\r
        ULONG                                           offset;\r
@@ -621,14 +582,7 @@ fw_access_ctrl(
                break;\r
                                \r
        case FW_OPEN_IF: // open BusInterface\r
-               if ( !p_context->fw_if_open ) {\r
-                       status = fw_get_pci_bus_interface(p_dev_obj, p_bus_interface);\r
-                       if ( NT_SUCCESS( status ) ) {\r
-                               p_context->fw_if_open = TRUE;\r
-                               // status can be positive, but != STATUS_SUCCESS\r
-                               status = STATUS_SUCCESS;\r
-                       }\r
-               }\r
+               __open_fw_access( p_context, p_bus_interface );\r
                break;\r
 \r
        case FW_READ: // read data from flash\r