From owner-svn-src-stable@freebsd.org Mon Aug 3 23:12:30 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70AF99B277D; Mon, 3 Aug 2015 23:12:30 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5DFCE995; Mon, 3 Aug 2015 23:12:30 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t73NCUuk063767; Mon, 3 Aug 2015 23:12:30 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t73NCTte063765; Mon, 3 Aug 2015 23:12:29 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201508032312.t73NCTte063765@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Mon, 3 Aug 2015 23:12:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r286263 - in stable/10/sys/dev/pms/freebsd/driver: common ini/src X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Aug 2015 23:12:30 -0000 Author: imp Date: Mon Aug 3 23:12:29 2015 New Revision: 286263 URL: https://svnweb.freebsd.org/changeset/base/286263 Log: MFC r286208: Only match devices that belong to this driver. Modified: stable/10/sys/dev/pms/freebsd/driver/common/lxutil.c stable/10/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/pms/freebsd/driver/common/lxutil.c ============================================================================== --- stable/10/sys/dev/pms/freebsd/driver/common/lxutil.c Mon Aug 3 23:08:40 2015 (r286262) +++ stable/10/sys/dev/pms/freebsd/driver/common/lxutil.c Mon Aug 3 23:12:29 2015 (r286263) @@ -19,6 +19,7 @@ *SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE ******************************************************************************/ +/* $FreeBSD$ */ /****************************************************************************** This program is part of PMC-Sierra initiator/target device driver. The functions here are commonly used by different type of drivers that support @@ -756,37 +757,30 @@ STATIC int agtiapi_ProbeCard( device_t d int thisCard ) { int idx; - static U32 cardMap[4] = { 0, 0, 0, 0 }; + u_int16_t agtiapi_vendor; // PCI vendor ID u_int16_t agtiapi_dev; // PCI device ID AGTIAPI_PRINTK("agtiapi_ProbeCard: start\n"); - if ( ! atomic_cmpset_32( &cardMap[thisCard], 0, 5 ) ) { // card already ran - AGTIAPI_PRINTK( "We'll only ID this card once -- %d\n", thisCard ); - return 2; // error return value; card already ran this function - } - else { - agtiapi_dev = pci_get_device( dev ); // get PCI device ID - for( idx = 0; idx < COUNT(ag_card_type); idx++ ) - { - if( ag_card_type[idx].deviceId == agtiapi_dev ) - { // device ID match - memset( (void *)&agCardInfoList[ thisCard ], 0, - sizeof(ag_card_info_t) ); - thisCardInst->cardIdIndex = idx; - thisCardInst->pPCIDev = dev; - thisCardInst->cardNameIndex = ag_card_type[idx].cardNameIndex; - thisCardInst->cardID = - pci_read_config( dev, ag_card_type[idx].membar, 4 ); // memAddr - AGTIAPI_PRINTK("agtiapi_ProbeCard: We've got PMC SAS, probe successful %p / %p\n", - thisCardInst->pPCIDev, thisCardInst ); - device_printf( dev, - "agtiapi PCI Probe Vendor ID : 0x%x Device ID : 0x%x\n", - pci_get_vendor(dev), agtiapi_dev ); - device_set_desc( dev, ag_card_names[ag_card_type[idx].cardNameIndex] ); - return 0; - } + agtiapi_vendor = pci_get_vendor( dev ); // get PCI vendor ID + agtiapi_dev = pci_get_device( dev ); // get PCI device ID + for( idx = 0; idx < COUNT(ag_card_type); idx++ ) + { + if ( ag_card_type[idx].deviceId == agtiapi_dev && + ag_card_type[idx].vendorId == agtiapi_vendor) + { // device ID match + memset( (void *)&agCardInfoList[ thisCard ], 0, + sizeof(ag_card_info_t) ); + thisCardInst->cardIdIndex = idx; + thisCardInst->pPCIDev = dev; + thisCardInst->cardNameIndex = ag_card_type[idx].cardNameIndex; + thisCardInst->cardID = + pci_read_config( dev, ag_card_type[idx].membar, 4 ); // memAddr + AGTIAPI_PRINTK("agtiapi_ProbeCard: We've got PMC SAS, probe successful %p / %p\n", + thisCardInst->pPCIDev, thisCardInst ); + device_set_desc( dev, ag_card_names[ag_card_type[idx].cardNameIndex] ); + return 0; } } - return 7; + return 1; } Modified: stable/10/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c ============================================================================== --- stable/10/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c Mon Aug 3 23:08:40 2015 (r286262) +++ stable/10/sys/dev/pms/freebsd/driver/ini/src/agtiapi.c Mon Aug 3 23:12:29 2015 (r286263) @@ -214,7 +214,6 @@ STATIC void agtiapi_CheckIOTimeout(void -static unsigned char cardMap[AGTIAPI_MAX_CARDS] = { 0, 0, 0, 0 }; static ag_card_info_t agCardInfoList[ AGTIAPI_MAX_CARDS ]; // card info list static void agtiapi_cam_action( struct cam_sim *, union ccb * ); static void agtiapi_cam_poll( struct cam_sim * ); @@ -695,37 +694,20 @@ Note: static int agtiapi_probe( device_t dev ) { int retVal; - - if ( pci_get_vendor(dev) == PCI_VENDOR_ID_PMC_SIERRA || - pci_get_vendor(dev) == PCI_VENDOR_ID_HIALEAH ) + int thisCard; + ag_card_info_t *thisCardInst; + + thisCard = device_get_unit( dev ); + if ( thisCard >= AGTIAPI_MAX_CARDS ) { - int thisCard = device_get_unit( dev ); -// AGTIAPI_PRINTK("agtiapi_probe: thisCard %d\n", thisCard); - if( thisCard >= AGTIAPI_MAX_CARDS) - { - device_printf( dev, "Too many PMC-Sierra cards detected ERROR!\n" ); - return (ENXIO); // maybe change to different return value? - } - ag_card_info_t *thisCardInst = &agCardInfoList[ thisCard ]; - retVal = agtiapi_ProbeCard( dev, thisCardInst, thisCard ); - if ( retVal ) { - // error on probe - if( retVal == 2 ) return 0; // another thread ran probe on this card - device_printf( dev, - "agtiapi_probe: PCI DEVICE NOT SUPPORTED by this driver!!" - "Vendor ID : 0x%x Device ID : 0x%x\n", - pci_get_vendor(dev), pci_get_device( dev ) ); - return (ENXIO); // maybe change to different return value? - } - else { - // AGTIAPI_PRINTK( "agtiapi_ProbeCard: returned with pointer values " - // "%p / %p\n", - // thisCardInst->pPCIDev, thisCardInst ); - cardMap[thisCard] = 11; // record this card is present - return( BUS_PROBE_DEFAULT ); // successful probe - } + device_printf( dev, "Too many PMC-Sierra cards detected ERROR!\n" ); + return (ENXIO); // maybe change to different return value? } - return (ENXIO); + thisCardInst = &agCardInfoList[ thisCard ]; + retVal = agtiapi_ProbeCard( dev, thisCardInst, thisCard ); + if ( retVal ) + return (ENXIO); // maybe change to different return value? + return( BUS_PROBE_DEFAULT ); // successful probe }