init_waitqueue_head(&adapter->int_waitq); 
init_completion(&adapter->int_waitq); 
megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id){	struct Scsi_Host *host;	adapter_t *adapter;	unsigned long mega_baseport, tbase, flag = 0;	u16 subsysid, subsysvid;	u8 pci_bus, pci_dev_func;	int irq, i, j;	int error = -ENODEV;	if (pci_enable_device(pdev))		goto out;	pci_set_master(pdev);	pci_bus = pdev->bus->number;	pci_dev_func = pdev->devfn;	/*	 * The megaraid3 stuff reports the ID of the Intel part which is not	 * remotely specific to the megaraid	 */	if (pdev->vendor == PCI_VENDOR_ID_INTEL) {		u16 magic;		/*		 * Don't fall over the Compaq management cards using the same		 * PCI identifier		 */		if (pdev->subsystem_vendor == PCI_VENDOR_ID_COMPAQ &&		    pdev->subsystem_device == 0xC000)		   	return -ENODEV;		/* Now check the magic signature byte */		pci_read_config_word(pdev, PCI_CONF_AMISIG, &magic);		if (magic != HBA_SIGNATURE_471 && magic != HBA_SIGNATURE)			return -ENODEV;		/* Ok it is probably a megaraid */	}	/*	 * For these vendor and device ids, signature offsets are not	 * valid and 64 bit is implicit	 */	if (id->driver_data & BOARD_64BIT)		flag |= BOARD_64BIT;	else {		u32 magic64;		pci_read_config_dword(pdev, PCI_CONF_AMISIG64, &magic64);		if (magic64 == HBA_SIGNATURE_64BIT)			flag |= BOARD_64BIT;	}	subsysvid = pdev->subsystem_vendor;	subsysid = pdev->subsystem_device;	printk(KERN_NOTICE "megaraid: found 0x%4.04x:0x%4.04x:bus %d:",		id->vendor, id->device, pci_bus);	printk("slot %d:func %d\n",		PCI_SLOT(pci_dev_func), PCI_FUNC(pci_dev_func));	/* Read the base port and IRQ from PCI */	mega_baseport = pci_resource_start(pdev, 0);	irq = pdev->irq;	tbase = mega_baseport;	if (pci_resource_flags(pdev, 0) & IORESOURCE_MEM) {		flag |= BOARD_MEMMAP;		if (!request_mem_region(mega_baseport, 128, "megaraid")) {			printk(KERN_WARNING "megaraid: mem region busy!\n");			goto out_disable_device;		}		mega_baseport = (unsigned long)ioremap(mega_baseport, 128);		if (!mega_baseport) {			printk(KERN_WARNING			       "megaraid: could not map hba memory\n");			goto out_release_region;		}	} else {		flag |= BOARD_IOMAP;		mega_baseport += 0x10;		if (!request_region(mega_baseport, 16, "megaraid"))			goto out_disable_device;	}	/* Initialize SCSI Host structure */	host = scsi_host_alloc(&megaraid_template, sizeof(adapter_t));	if (!host)		goto out_iounmap;	adapter = (adapter_t *)host->hostdata;	memset(adapter, 0, sizeof(adapter_t));	printk(KERN_NOTICE		"scsi%d:Found MegaRAID controller at 0x%lx, IRQ:%d\n",		host->host_no, mega_baseport, irq);	adapter->base = mega_baseport;	INIT_LIST_HEAD(&adapter->free_list);	INIT_LIST_HEAD(&adapter->pending_list);	INIT_LIST_HEAD(&adapter->completed_list);	adapter->flag = flag;	spin_lock_init(&adapter->lock);	scsi_assign_lock(host, &adapter->lock);	host->cmd_per_lun = max_cmd_per_lun;	host->max_sectors = max_sectors_per_io;	adapter->dev = pdev;	adapter->host = host;	adapter->host->irq = irq;	if (flag & BOARD_MEMMAP)		adapter->host->base = tbase;	else {		adapter->host->io_port = tbase;		adapter->host->n_io_port = 16;	}	adapter->host->unique_id = (pci_bus << 8) | pci_dev_func;	/*	 * Allocate buffer to issue internal commands.	 */	adapter->mega_buffer = pci_alloc_consistent(adapter->dev,		MEGA_BUFFER_SIZE, &adapter->buf_dma_handle);	if (!adapter->mega_buffer) {		printk(KERN_WARNING "megaraid: out of RAM.\n");		goto out_host_put;	}	adapter->scb_list = kmalloc(sizeof(scb_t) * MAX_COMMANDS, GFP_KERNEL);	if (!adapter->scb_list) {		printk(KERN_WARNING "megaraid: out of RAM.\n");		goto out_free_cmd_buffer;	}	if (request_irq(irq, (adapter->flag & BOARD_MEMMAP) ?				megaraid_isr_memmapped : megaraid_isr_iomapped,					SA_SHIRQ, "megaraid", adapter)) {		printk(KERN_WARNING			"megaraid: Couldn't register IRQ %d!\n", irq);		goto out_free_scb_list;	}	if (mega_setup_mailbox(adapter))		goto out_free_irq;	if (mega_query_adapter(adapter))		goto out_free_mbox;	/*	 * Have checks for some buggy f/w	 */	if ((subsysid == 0x1111) && (subsysvid == 0x1111)) {		/*		 * Which firmware		 */		if (!strcmp(adapter->fw_version, "3.00") ||				!strcmp(adapter->fw_version, "3.01")) {			printk( KERN_WARNING				"megaraid: Your  card is a Dell PERC "				"2/SC RAID controller with  "				"firmware\nmegaraid: 3.00 or 3.01.  "				"This driver is known to have "				"corruption issues\nmegaraid: with "				"those firmware versions on this "				"specific card.  In order\nmegaraid: "				"to protect your data, please upgrade "				"your firmware to version\nmegaraid: "				"3.10 or later, available from the "				"Dell Technical Support web\n"				"megaraid: site at\nhttp://support."				"dell.com/us/en/filelib/download/"				"index.asp?fileid=2940\n"			);		}	}	/*	 * If we have a HP 1M(0x60E7)/2M(0x60E8) controller with	 * firmware H.01.07, H.01.08, and H.01.09 disable 64 bit	 * support, since this firmware cannot handle 64 bit	 * addressing	 */	if ((subsysvid == HP_SUBSYS_VID) &&	    ((subsysid == 0x60E7) || (subsysid == 0x60E8))) {		/*		 * which firmware		 */		if (!strcmp(adapter->fw_version, "H01.07") ||		    !strcmp(adapter->fw_version, "H01.08") ||		    !strcmp(adapter->fw_version, "H01.09") ) {			printk(KERN_WARNING				"megaraid: Firmware H.01.07, "				"H.01.08, and H.01.09 on 1M/2M "				"controllers\n"				"megaraid: do not support 64 bit "				"addressing.\nmegaraid: DISABLING "				"64 bit support.\n");			adapter->flag &= ~BOARD_64BIT;		}	}	if (mega_is_bios_enabled(adapter))		mega_hbas[hba_count].is_bios_enabled = 1;	mega_hbas[hba_count].hostdata_addr = adapter;	/*	 * Find out which channel is raid and which is scsi. This is	 * for ROMB support.	 */	mega_enum_raid_scsi(adapter);	/*	 * Find out if a logical drive is set as the boot drive. If	 * there is one, will make that as the first logical drive.	 * ROMB: Do we have to boot from a physical drive. Then all	 * the physical drives would appear before the logical disks.	 * Else, all the physical drives would be exported to the mid	 * layer after logical drives.	 */	mega_get_boot_drv(adapter);	if (adapter->boot_pdrv_enabled) {		j = adapter->product_info.nchannels;		for( i = 0; i < j; i++ )			adapter->logdrv_chan[i] = 0;		for( i = j; i < NVIRT_CHAN + j; i++ )			adapter->logdrv_chan[i] = 1;	} else {		for (i = 0; i < NVIRT_CHAN; i++)			adapter->logdrv_chan[i] = 1;		for (i = NVIRT_CHAN; i < MAX_CHANNELS+NVIRT_CHAN; i++)			adapter->logdrv_chan[i] = 0;		adapter->mega_ch_class <<= NVIRT_CHAN;	}	/*	 * Do we support random deletion and addition of logical	 * drives	 */	adapter->read_ldidmap = 0;	/* set it after first logdrv						   delete cmd */	adapter->support_random_del = mega_support_random_del(adapter);	/* Initialize SCBs */	if (mega_init_scb(adapter))		goto out_free_mbox;	/*	 * Reset the pending commands counter	 */	atomic_set(&adapter->pend_cmds, 0);	/*	 * Reset the adapter quiescent flag	 */	atomic_set(&adapter->quiescent, 0);	hba_soft_state[hba_count] = adapter;	/*	 * Fill in the structure which needs to be passed back to the	 * application when it does an ioctl() for controller related	 * information.	 */	i = hba_count;	mcontroller[i].base = mega_baseport;	mcontroller[i].irq = irq;	mcontroller[i].numldrv = adapter->numldrv;	mcontroller[i].pcibus = pci_bus;	mcontroller[i].pcidev = id->device;	mcontroller[i].pcifun = PCI_FUNC (pci_dev_func);	mcontroller[i].pciid = -1;	mcontroller[i].pcivendor = id->vendor;	mcontroller[i].pcislot = PCI_SLOT(pci_dev_func);	mcontroller[i].uid = (pci_bus << 8) | pci_dev_func;	/* Set the Mode of addressing to 64 bit if we can */	if ((adapter->flag & BOARD_64BIT) && (sizeof(dma_addr_t) == 8)) {		pci_set_dma_mask(pdev, 0xffffffffffffffffULL);		adapter->has_64bit_addr = 1;	} else  {		pci_set_dma_mask(pdev, 0xffffffff);		adapter->has_64bit_addr = 0;	}			init_MUTEX(&adapter->int_mtx);	init_waitqueue_head(&adapter->int_waitq);	adapter->this_id = DEFAULT_INITIATOR_ID;	adapter->host->this_id = DEFAULT_INITIATOR_ID;#if MEGA_HAVE_CLUSTERING	/*	 * Is cluster support enabled on this controller	 * Note: In a cluster the HBAs ( the initiators ) will have	 * different target IDs and we cannot assume it to be 7. Call	 * to mega_support_cluster() will get the target ids also if	 * the cluster support is available	 */	adapter->has_cluster = mega_support_cluster(adapter);	if (adapter->has_cluster) {		printk(KERN_NOTICE			"megaraid: Cluster driver, initiator id:%d\n",			adapter->this_id);	}#endif	pci_set_drvdata(pdev, host);	mega_create_proc_entry(hba_count, mega_proc_dir_entry);	error = scsi_add_host(host, &pdev->dev);	if (error)		goto out_free_mbox;	scsi_scan_host(host);	hba_count++;	return 0; out_free_mbox:	pci_free_consistent(adapter->dev, sizeof(mbox64_t),			adapter->una_mbox64, adapter->una_mbox64_dma); out_free_irq:	free_irq(adapter->host->irq, adapter); out_free_scb_list:	kfree(adapter->scb_list); out_free_cmd_buffer:	pci_free_consistent(adapter->dev, MEGA_BUFFER_SIZE,			adapter->mega_buffer, adapter->buf_dma_handle); out_host_put:	scsi_host_put(host); out_iounmap:	if (flag & BOARD_MEMMAP)		iounmap((void *)mega_baseport); out_release_region:	if (flag & BOARD_MEMMAP)		release_mem_region(tbase, 128);	else		release_region(mega_baseport, 16); out_disable_device:	pci_disable_device(pdev); out:	return error;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/8d115f845a0bd59cd263e791f739964f42b7b0e8/megaraid.c/buggy/drivers/scsi/megaraid.c