From: stansmith Date: Wed, 6 Aug 2008 21:08:11 +0000 (+0000) Subject: [IBBUS] fixed duplicate bus relations reporting, which also fixed the problem of... X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=30eec73ab81816aba3164d2c5b52082f50b3501d;p=~shefty%2Frdma-win.git [IBBUS] fixed duplicate bus relations reporting, which also fixed the problem of a required reboot. Now the IB stack can be uninstalled and installed without requiring a reboot. git-svn-id: svn://openib.tc.cornell.edu/gen1@1468 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- diff --git a/branches/winverbs/core/bus/kernel/bus_iou_mgr.c b/branches/winverbs/core/bus/kernel/bus_iou_mgr.c index d5391740..2db2fc78 100644 --- a/branches/winverbs/core/bus/kernel/bus_iou_mgr.c +++ b/branches/winverbs/core/bus/kernel/bus_iou_mgr.c @@ -621,7 +621,7 @@ __iou_was_hibernated( bus_pdo_ext_t *p_pdo_ext = NULL; size_t n_devs = 0; iou_mgr_t *gp_iou_mgr = p_bfi->p_iou_mgr; - cl_qlist_t* p_pdo_list = &gp_iou_mgr->iou_list; + cl_qlist_t *p_pdo_list = &gp_iou_mgr->iou_list; iou_pnp_ctx_t *p_ctx = p_pnp_rec->pnp_rec.context; BUS_ENTER( BUS_DBG_PNP ); @@ -659,7 +659,8 @@ __iou_was_hibernated( p_pdo_ext->h_ca = acquire_ca( p_pnp_rec->ca_guid ); if( !p_pdo_ext->h_ca ) { - BUS_TRACE( BUS_DBG_ERROR, ("acquire_ca failed to find CA by guid %I64x\n", + BUS_TRACE( BUS_DBG_ERROR, + ("acquire_ca failed to find CA by guid %I64x\n", p_pnp_rec->ca_guid ) ); status = IB_INVALID_GUID; } @@ -707,8 +708,8 @@ iou_mgr_iou_add( p_bfi = get_set_bfi_by_ca_guid( p_pnp_rec->ca_guid ); if ( !p_bfi ) { - BUS_PRINT( BUS_DBG_PNP,("%s() NULL p_bfi? ca_guid 0x%I64x\n", - __FUNCTION__, p_pnp_rec->ca_guid ) ); + BUS_TRACE_EXIT( BUS_DBG_PNP,("%s() NULL p_bfi? ca_guid 0x%I64x\n", + __FUNCTION__, p_pnp_rec->ca_guid ) ); return IB_ERROR; } @@ -720,7 +721,7 @@ iou_mgr_iou_add( p_ctx = cl_zalloc( sizeof(*p_ctx) ); if( !p_ctx ) { - BUS_PRINT(BUS_DBG_PNP, ("%s(%s) ca_guid 0x%I64x iou_guid(%I64x) " + BUS_TRACE_EXIT(BUS_DBG_PNP, ("%s(%s) ca_guid %I64x iou_guid(%I64x) " "BAD alloc for PNP context\n", __FUNCTION__, p_bfi->whoami, p_bfi->ca_guid, p_pnp_rec->guid )); @@ -819,12 +820,6 @@ iou_mgr_iou_add( IoInvalidateDeviceRelations( p_iou_ext->pdo.h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations ); -#if 0 // XXX - /* Invalidate removal relations for the bus driver. */ - IoInvalidateDeviceRelations( - p_bfi->p_bus_ext->cl_ext.p_pdo, RemovalRelations ); -#endif - BUS_EXIT( BUS_DBG_PNP ); return IB_SUCCESS; @@ -866,7 +861,7 @@ iou_mgr_iou_remove( gp_iou_mgr = p_bfi->p_iou_mgr; - /* Within the Bus fabric instance is the port extension; see + /* Within the PNP record's context is the IOU extension; see * was_hibernated(). */ p_ext = p_ctx->p_pdo_ext; @@ -889,7 +884,7 @@ iou_mgr_iou_remove( cl_mutex_acquire( &gp_iou_mgr->pdo_mutex ); if ( !p_ext->h_ca ) { - BUS_TRACE( BUS_DBG_PNP, ("%s() NULL h_ca? p_ext %p\n", + BUS_TRACE_EXIT( BUS_DBG_PNP, ("%s() NULL h_ca? p_ext %p\n", __FUNCTION__, p_ext ) ); return; } @@ -913,12 +908,6 @@ iou_mgr_iou_remove( p_ext->cl_ext.vfptr_pnp_po->identity, p_ext, p_ext->b_present, p_ext->b_reported_missing ) ); -#if 0 // XXX - /* Invalidate removal relations for the bus driver. */ - IoInvalidateDeviceRelations( p_bfi->p_bus_ext->cl_ext.p_pdo, - RemovalRelations ); -#endif - /* Invalidate bus relations for the HCA. */ IoInvalidateDeviceRelations( p_ext->h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations ); diff --git a/branches/winverbs/core/bus/kernel/bus_pnp.c b/branches/winverbs/core/bus/kernel/bus_pnp.c index 8c2d61b7..43c13e7a 100644 --- a/branches/winverbs/core/bus/kernel/bus_pnp.c +++ b/branches/winverbs/core/bus/kernel/bus_pnp.c @@ -153,9 +153,9 @@ static const cl_vfptr_pnp_po_t vfptr_fdo_pnp = { cl_irp_skip, cl_irp_skip, cl_do_sync_pnp, - fdo_query_bus_relations /*cl_irp_ignore*/ , + fdo_query_bus_relations, cl_irp_ignore, - cl_irp_skip /*fdo_query_remove_relations now _bus_relations */ , + cl_irp_skip, cl_irp_ignore, cl_irp_ignore, cl_irp_ignore, @@ -191,7 +191,7 @@ bus_add_device( p_bfi = alloc_bfi( p_driver_obj, &ic ); if ( !p_bfi ) { - BUS_PRINT( BUS_DBG_PNP, + BUS_TRACE_EXIT( BUS_DBG_PNP, ("%s() Err - Exceeded MAX_BUS_FILTERS(%d)\n",MAX_BUS_FILTERS)); return STATUS_UNSUCCESSFUL; } @@ -209,7 +209,7 @@ bus_add_device( FILE_DEVICE_SECURE_OPEN, FALSE, &p_dev_obj ); if( !NT_SUCCESS(status) ) { - BUS_TRACE_EXIT( BUS_DBG_ERROR, + BUS_PRINT( BUS_DBG_ERROR, ("Failed to create ControlDeviceObject, status %x.\n",status) ); goto bail; } @@ -218,7 +218,7 @@ bus_add_device( if( !NT_SUCCESS(status) ) { IoDeleteDevice( p_dev_obj ); - BUS_TRACE_EXIT( BUS_DBG_ERROR, + BUS_PRINT( BUS_DBG_ERROR, ("Failed to create symlink for dos name.\n") ); goto bail; } @@ -227,13 +227,12 @@ bus_add_device( status = IoCreateDevice( p_driver_obj, sizeof(bus_fdo_ext_t), NULL, FILE_DEVICE_BUS_EXTENDER, FILE_DEVICE_SECURE_OPEN, FALSE, &p_dev_obj ); - } - - if( !NT_SUCCESS(status) ) - { - BUS_TRACE_EXIT( BUS_DBG_ERROR, - ("Failed to create bus root FDO device.\n") ); - goto bail; + if( !NT_SUCCESS(status) ) + { + BUS_PRINT( BUS_DBG_ERROR, + ("Failed to create bus root FDO device.\n") ); + goto bail; + } } p_ext = p_dev_obj->DeviceExtension; @@ -244,7 +243,7 @@ bus_add_device( if( !p_next_do ) { IoDeleteDevice( p_dev_obj ); - BUS_TRACE_EXIT( BUS_DBG_ERROR, ("IoAttachToDeviceStack failed.\n") ); + BUS_PRINT( BUS_DBG_ERROR, ("IoAttachToDeviceStack failed.\n") ); status = STATUS_NO_SUCH_DEVICE; goto bail; } @@ -268,7 +267,7 @@ bus_add_device( { IoDetachDevice( p_ext->cl_ext.p_next_do ); IoDeleteDevice( p_dev_obj ); - BUS_TRACE_EXIT( BUS_DBG_ERROR, + BUS_PRINT( BUS_DBG_ERROR, ("IoRegisterDeviceInterface for upper interface returned %08x\n", status) ); status = STATUS_NO_SUCH_DEVICE; @@ -282,7 +281,7 @@ bus_add_device( { IoDetachDevice( p_ext->cl_ext.p_next_do ); IoDeleteDevice( p_dev_obj ); - BUS_TRACE_EXIT( BUS_DBG_ERROR, + BUS_PRINT( BUS_DBG_ERROR, ("IoRegisterDeviceInterface for lower interface returned %08x\n", status) ); status = STATUS_NO_SUCH_DEVICE; @@ -297,7 +296,7 @@ adxit: return STATUS_SUCCESS; bail: - BUS_PRINT( BUS_DBG_PNP, ("%s(%s) exit status %d\n", + BUS_PRINT( BUS_DBG_PNP, ("%s(%s) exit status 0x%x\n", __FUNCTION__,p_bfi->whoami,status) ); ic = free_bfi(p_bfi); /* if last Bus filter, then cleanup */ @@ -394,6 +393,7 @@ fdo_query_remove( OUT cl_irp_action_t* const p_action ) { bus_fdo_ext_t *p_ext; + bus_filter_t *p_bfi; BUS_ENTER( BUS_DBG_PNP ); @@ -402,7 +402,7 @@ fdo_query_remove( BUS_PRINT( BUS_DBG_PNP, ("%s() IRP_MN_QUERY_REMOVE_DEVICE %s @ %p refs CI %d AL %d\n", __FUNCTION__, p_ext->cl_ext.vfptr_pnp_po->identity, p_ext, - p_ext->n_ci_ifc_ref,p_ext->n_al_ifc_ref ) ); // XXX + p_ext->n_ci_ifc_ref,p_ext->n_al_ifc_ref ) ); if( p_ext->n_ci_ifc_ref ) { @@ -421,9 +421,23 @@ fdo_query_remove( return STATUS_UNSUCCESSFUL; } + /* remove port & iou managers */ + p_bfi = p_ext->bus_filter; + CL_ASSERT( p_bfi ); + + //TODO: Fail outstanding I/O operations. + + if ( p_ext->p_port_mgr && p_bfi->p_port_mgr ) + cl_obj_destroy( &p_ext->p_port_mgr->obj ); + + if ( p_ext->p_iou_mgr && p_bfi->p_iou_mgr ) + cl_obj_destroy( &p_ext->p_iou_mgr->obj ); + + *p_action = IrpSkip; /* The FDO driver must set the status even when passing down. */ p_irp->IoStatus.Status = STATUS_SUCCESS; + BUS_EXIT( BUS_DBG_PNP ); return STATUS_SUCCESS; } @@ -448,16 +462,17 @@ fdo_release_resources( p_ext = p_dev_obj->DeviceExtension; ic = get_bfi_count(); + p_bfi = p_ext->bus_filter; + CL_ASSERT( p_bfi ); + //TODO: Fail outstanding I/O operations. - if (p_ext->p_port_mgr) + if ( p_ext->p_port_mgr && p_bfi->p_port_mgr ) cl_obj_destroy( &p_ext->p_port_mgr->obj ); - if (p_ext->p_iou_mgr) + if ( p_ext->p_iou_mgr && p_bfi->p_iou_mgr ) cl_obj_destroy( &p_ext->p_iou_mgr->obj ); - p_bfi = p_ext->bus_filter; - CL_ASSERT( p_bfi ); BUS_PRINT( BUS_DBG_PNP, ("%s() Releasing BusFilter %s\n", __FUNCTION__, p_bfi->whoami )); if (p_bfi) { @@ -530,70 +545,31 @@ fdo_query_capabilities( } -#if 0 // XXX - static NTSTATUS -fdo_query_removal_relations( +fdo_query_bus_relations( IN DEVICE_OBJECT* const p_dev_obj, IN IRP* const p_irp, OUT cl_irp_action_t* const p_action ) { NTSTATUS status; - UNUSED_PARAM( p_dev_obj ); + bus_fdo_ext_t *p_ext; + bus_filter_t *p_bfi; BUS_ENTER( BUS_DBG_PNP ); - status = port_mgr_get_bus_relations( 0, p_irp ); - if( status == STATUS_SUCCESS || - status == STATUS_NO_SUCH_DEVICE ) - { - status = iou_mgr_get_bus_relations( 0, p_irp ); - } - if( status == STATUS_NO_SUCH_DEVICE ) - status = STATUS_SUCCESS; + p_ext = p_dev_obj->DeviceExtension; - switch( status ) + if ( !p_ext->bus_filter ) { - case STATUS_NO_SUCH_DEVICE: - *p_action = IrpSkip; - status = STATUS_SUCCESS; - break; - - case STATUS_SUCCESS: - *p_action = IrpPassDown; - break; - - default: + /* BFI has already been released */ *p_action = IrpComplete; - break; + BUS_TRACE_EXIT( BUS_DBG_PNP, ("%s() NULL BFI\n", __FUNCTION__) ); + return STATUS_SUCCESS; } - BUS_EXIT( BUS_DBG_PNP ); - return status; -} -#endif - - -static NTSTATUS -fdo_query_bus_relations( - IN DEVICE_OBJECT* const p_dev_obj, - IN IRP* const p_irp, - OUT cl_irp_action_t* const p_action ) -{ - NTSTATUS status; - bus_fdo_ext_t *p_ext; - bus_filter_t *p_bfi; - - BUS_ENTER( BUS_DBG_PNP ); - - p_ext = p_dev_obj->DeviceExtension; - CL_ASSERT( p_ext->bus_filter ); p_bfi = p_ext->bus_filter; CL_ASSERT( p_bfi->magic == BFI_MAGIC ); - BUS_PRINT( BUS_DBG_PNP, ("%s(%s) ca_guid %I64x\n", - __FUNCTION__,p_bfi->whoami, p_bfi->ca_guid) ); - if ( p_bfi->ca_guid == 0ULL ) { /* HCA not yet bound to a BFI slot (no PNP ADD event seen), no bus @@ -647,8 +623,6 @@ al_ref_ifc( cl_atomic_inc( &p_ext->n_al_ifc_ref ); ObReferenceObject( p_dev_obj ); - BUS_PRINT( BUS_DBG_PNP, (" %p->n_al_ifc_ref %d\n", - p_ext,p_ext->n_al_ifc_ref )); // XXX BUS_EXIT( BUS_DBG_PNP ); } @@ -666,8 +640,6 @@ al_deref_ifc( cl_atomic_dec( &p_ext->n_al_ifc_ref ); ObDereferenceObject( p_dev_obj ); - BUS_PRINT( BUS_DBG_PNP, (" %p->n_al_ifc_ref %d\n", - p_ext,p_ext->n_al_ifc_ref )); // XXX BUS_EXIT( BUS_DBG_PNP ); } @@ -685,8 +657,6 @@ al_ref_ci_ifc( cl_atomic_inc( &p_ext->n_ci_ifc_ref ); ObReferenceObject( p_dev_obj ); - BUS_PRINT( BUS_DBG_PNP, (" %p->n_ci_ifc_ref %d\n", - p_ext,p_ext->n_ci_ifc_ref )); // XXX BUS_EXIT( BUS_DBG_PNP ); } @@ -704,8 +674,6 @@ al_deref_ci_ifc( cl_atomic_dec( &p_ext->n_ci_ifc_ref ); ObDereferenceObject( p_dev_obj ); - BUS_PRINT( BUS_DBG_PNP, (" %p->n_ci_ifc_ref %d\n", - p_ext,p_ext->n_ci_ifc_ref )); // XXX BUS_EXIT( BUS_DBG_PNP ); } @@ -869,22 +837,18 @@ __get_relations( IN const net64_t ca_guid, IN IRP* const p_irp ) { - NTSTATUS status; - BUS_ENTER( BUS_DBG_PNP ); + UNUSED_PARAM( ca_guid ); + UNUSED_PARAM( p_irp ); - /* TODO: For IOUs, filter relations based on multi-HCA support. */ - status = port_mgr_get_bus_relations( ca_guid, p_irp ); - if( status == STATUS_SUCCESS || - status == STATUS_NO_SUCH_DEVICE ) - { - status = iou_mgr_get_bus_relations( ca_guid, p_irp ); - } - if( status == STATUS_NO_SUCH_DEVICE ) - status = STATUS_SUCCESS; + /* + * Now that ibbus is in the same device stack as the HCA driver, skip + * returning relations here as ibbus has already done the deed. + * This interface remains to minimize changes to HCA drivers for now. + */ BUS_EXIT( BUS_DBG_PNP ); - return status; + return STATUS_SUCCESS; } diff --git a/branches/winverbs/core/bus/kernel/bus_port_mgr.c b/branches/winverbs/core/bus/kernel/bus_port_mgr.c index 31837284..19891eeb 100644 --- a/branches/winverbs/core/bus/kernel/bus_port_mgr.c +++ b/branches/winverbs/core/bus/kernel/bus_port_mgr.c @@ -456,11 +456,6 @@ free_port_mgr( p_bfi->whoami, p_ext->cl_ext.vfptr_pnp_po->identity, p_ext->cl_ext.p_self_do, p_ext ) ); - BUS_TRACE( BUS_DBG_PNP,("%s(%s) h_ca->obj.state %s refs %d\n", - __FUNCTION__, p_bfi->whoami, - get_obj_state_str(p_ext->h_ca->obj.state), - p_ext->h_ca->obj.ref_cnt)); // XXX - IoDeleteDevice( p_ext->cl_ext.p_self_do ); } @@ -611,8 +606,7 @@ __port_was_hibernated( bus_pdo_ext_t *p_pdo_ext = NULL; size_t n_devs = 0; port_mgr_t *gp_port_mgr = p_bfi->p_port_mgr; - cl_qlist_t* p_pdo_list = &gp_port_mgr->port_list; - + cl_qlist_t *p_pdo_list = &gp_port_mgr->port_list; port_pnp_ctx_t *p_ctx = p_pnp_rec->pnp_rec.context; BUS_ENTER( BUS_DBG_PNP ); @@ -685,6 +679,7 @@ __port_was_hibernated( return status; } +#if DBG void dump_pnp_port_rec( ib_pnp_port_rec_t* pr ) @@ -746,6 +741,7 @@ dump_pnp_iou_rec( ib_pnp_iou_rec_t* pr ) BUS_PRINT( BUS_DBG_PNP, (" Desc %s\n",pr->desc )); } } +#endif ib_api_status_t @@ -767,7 +763,7 @@ port_mgr_port_add( p_bfi = get_set_bfi_by_ca_guid( p_pnp_rec->p_ca_attr->ca_guid ); if ( !p_bfi ) { - BUS_PRINT( BUS_DBG_PNP,("%s() NULL p_bfi? ca_guid 0x%I64x\n", + BUS_TRACE_EXIT( BUS_DBG_PNP,("%s() NULL p_bfi? ca_guid 0x%I64x\n", __FUNCTION__, p_pnp_rec->p_ca_attr->ca_guid ) ); return IB_ERROR; } @@ -779,7 +775,7 @@ port_mgr_port_add( p_ctx = cl_zalloc( sizeof(*p_ctx) ); if( !p_ctx ) { - BUS_PRINT(BUS_DBG_PNP, + BUS_TRACE_EXIT(BUS_DBG_PNP, ("%s(%s) ca_guid %I64x port(%d) BAD alloc PNP context\n", __FUNCTION__, p_bfi->whoami, p_bfi->ca_guid, p_pnp_rec->p_port_attr->port_num)); @@ -905,12 +901,6 @@ port_mgr_port_add( IoInvalidateDeviceRelations( p_port_ext->pdo.h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations ); -#if 0 // XXX - /* Invalidate removal relations for the bus driver. */ - IoInvalidateDeviceRelations( p_bfi->p_bus_ext->cl_ext.p_pdo, - RemovalRelations ); -#endif - BUS_EXIT( BUS_DBG_PNP ); return IB_SUCCESS; } @@ -1015,16 +1005,11 @@ cl_status_t port_mgr_pkey_add(pkey_array_t *pkeys) IoInvalidateDeviceRelations( p_port_ext->pdo.h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations ); -#if 0 // XXX - /* Invalidate removal relations for the bus driver. */ - IoInvalidateDeviceRelations( p_bfi->p_bus_ext->cl_ext.p_pdo, - RemovalRelations ); -#endif - BUS_EXIT( BUS_DBG_PNP ); return CL_SUCCESS; } + void port_mgr_port_remove( IN ib_pnp_port_rec_t* p_pnp_rec ) @@ -1068,16 +1053,7 @@ port_mgr_port_remove( */ p_ext = p_ctx->p_pdo_ext; CL_ASSERT( p_ext ); - CL_ASSERT(p_bfi == p_ext->p_parent_ext->bus_filter); -#if DBG // XXX - if (p_bfi != p_ext->p_parent_ext->bus_filter) { - BUS_PRINT(BUS_DBG_PNP, - ("%s() p_bfi(%p) != p_ext->bus_filter(%p) line %d file %s\n", - __FUNCTION__,p_bfi,p_ext->p_parent_ext->bus_filter, - __LINE__,__FILE__)); - } -#endif /* * Flag the port PDO as no longer being present. We have to wait until @@ -1087,7 +1063,7 @@ port_mgr_port_remove( */ if ( !p_ext->h_ca ) { - BUS_TRACE( BUS_DBG_PNP, ("%s() %s NULL h_ca? p_ext %p\n", + BUS_TRACE_EXIT( BUS_DBG_PNP, ("%s() %s NULL h_ca? p_ext %p\n", __FUNCTION__, p_bfi->whoami, p_ext ) ); return; } @@ -1113,12 +1089,6 @@ port_mgr_port_remove( p_ext->cl_ext.vfptr_pnp_po->identity, p_ext->cl_ext.p_self_do, p_ext, p_ext->b_present, p_ext->b_reported_missing ) ); -#if 0 // XXX - /* Invalidate removal relations for the bus driver. */ - IoInvalidateDeviceRelations( p_bfi->p_bus_ext->cl_ext.p_pdo, - RemovalRelations ); -#endif - /* Invalidate bus relations for the HCA. */ IoInvalidateDeviceRelations( p_ext->h_ca->obj.p_ci_ca->verbs.p_hca_dev, BusRelations ); @@ -1173,9 +1143,6 @@ port_query_remove( p_ext = p_dev_obj->DeviceExtension; -BUS_PRINT( BUS_DBG_PNP, ("%s() %p->n_ifc_ref %d\n", - __FUNCTION__,p_ext,p_ext->n_ifc_ref )); - *p_action = IrpComplete; if( p_ext->n_ifc_ref ) { @@ -1270,9 +1237,10 @@ port_remove( p_irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest( p_irp, IO_NO_INCREMENT ); - BUS_PRINT/*XXX TRACE*/( BUS_DBG_PNP, ("Deleted device %s: PDO %p(=%p), ext %p\n", + BUS_TRACE( BUS_DBG_PNP, ("Deleted device %s: PDO %p(=%p), ext %p\n", p_ext->pdo.cl_ext.vfptr_pnp_po->identity, p_ext->pdo.cl_ext.p_self_do, p_dev_obj, p_ext ) ); + IoDeleteDevice( p_dev_obj ); *p_action = IrpDoNothing; @@ -1770,9 +1738,6 @@ port_query_ipoib_ifc( p_ipoib_data->port_guid = p_ext->port_guid; p_ipoib_data->port_num = (uint8_t)p_ext->n_port; - BUS_TRACE_EXIT( BUS_DBG_PNP, - (" %p->n_ifc_ref %d\n",p_ext,p_ext->n_ifc_ref) ); //XXX - BUS_EXIT( BUS_DBG_PNP ); return STATUS_SUCCESS; }