⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rhel3-ga.patch

📁 最新的Megaraid SAS卡驱动源代码
💻 PATCH
📖 第 1 页 / 共 5 页
字号:
+ 	spin_lock_init(&instance->pending_lock); 	spin_lock_init(&instance->completion_lock);  	sema_init(&instance->aen_mutex, 1); 	sema_init(&instance->ioctl_sem, MEGASAS_INT_CMDS); +	/** +	for-ioctl: initialize ioctl memory list and memory lock +	**/++	for (i=0; i<MAX_IOCTL_MEM_POOL; i++) {+		INIT_LIST_HEAD(&instance->ioctl_memory_pool[i]);+	}++	if(megasas_setup_mem_pools(instance))+		instance->mem_pool_empty=1;+	+	/* end for-ioctl */+ 	/* 	 * Initialize PCI related and misc parameters 	 */@@ -2635,8 +2835,8 @@ megasas_probe_one(struct pci_dev *pdev,  	instance->init_id = MEGASAS_DEFAULT_INIT_ID;  	megasas_dbg_lvl = 0;-	instance->flag = 0;-	instance->last_time = 0;+	instance->is_busy=0;+	instance->last_time=0;  	/* 	 * Initialize MFI Firmware@@ -2647,7 +2847,7 @@ megasas_probe_one(struct pci_dev *pdev,  	/* 	 * Register IRQ 	 */-	if (request_irq(pdev->irq, megasas_isr, IRQF_SHARED, "megasas", instance)) {+	if (request_irq(pdev->irq, megasas_isr, SA_SHIRQ, "megasas", instance)) { 		printk(KERN_DEBUG "megasas: Failed to register IRQ\n"); 		goto fail_irq; 	}@@ -2680,6 +2880,10 @@ megasas_probe_one(struct pci_dev *pdev,  	 */ 	if (megasas_io_attach(instance)) 		goto fail_io_attach;+#if CONFIG_PROC_FS+	if (megasas_proc_hba_map)+		megasas_create_proc_entry(instance);+#endif  	return 0; @@ -2698,6 +2902,8 @@ megasas_probe_one(struct pci_dev *pdev,        fail_irq:       fail_init_mfi:       fail_alloc_dma_buf:+	/* Free the ioctl mem pool */+	megasas_free_ioctl_mem_pools(instance); 	if (instance->evt_detail) 		pci_free_consistent(pdev, sizeof(struct megasas_evt_detail), 				    instance->evt_detail,@@ -2718,6 +2924,32 @@ megasas_probe_one(struct pci_dev *pdev,  	return -ENODEV; } +static int megasas_detect(Scsi_Host_Template * sht)+{+	int i = 0;+	u16 ven;+	u16 dev;+	int hba_count = 0;+	struct pci_dev *pdev = NULL;+	struct pci_device_id *pid;++	for (i = 0;; i++) {+		if (!megasas_pci_table[i].vendor)+			break;++		pid = &megasas_pci_table[i];+		ven = megasas_pci_table[i].vendor;+		dev = megasas_pci_table[i].device;++		while ((pdev = (pci_find_device(ven, dev, pdev)))) {+			if (!megasas_probe_one(pdev, pid, sht))+				hba_count++;+		}+	}++	return hba_count;+}+ /**  * megasas_flush_cache -	Requests FW to flush all its caches  * @instance:			Adapter soft state@@ -2753,12 +2985,41 @@ static void megasas_flush_cache(struct m }  /**+ * megasas_reboot_notify-	Flush adapter cache+ * @this:			Our notifier block+ * @code:			The event notified+ * @unused:			Unused+ */++static int+megasas_reboot_notify (struct notifier_block *this, unsigned long code,+		void *unused)+{+	struct megasas_instance *instance;+	int i;++	for (i = 0; i < megasas_mgmt_info.max_index; i++) {+		instance = megasas_mgmt_info.instance[i];+		if (instance) {+			megasas_flush_cache(instance);+		}+	}++	return NOTIFY_DONE;+}++/**+ * notifier block to get notification on system halt/reboot/shutdown/power off+ */+static struct notifier_block megasas_notifier = {+	.notifier_call = megasas_reboot_notify+};++/**  * megasas_shutdown_controller -	Instructs FW to shutdown the controller  * @instance:				Adapter soft state- * @opcode:				Shutdown/Hibernate  */-static void megasas_shutdown_controller(struct megasas_instance *instance,-					u32 opcode)+static void megasas_shutdown_controller(struct megasas_instance *instance) { 	struct megasas_cmd *cmd; 	struct megasas_dcmd_frame *dcmd;@@ -2781,7 +3042,7 @@ static void megasas_shutdown_controller( 	dcmd->flags = MFI_FRAME_DIR_NONE; 	dcmd->timeout = 0; 	dcmd->data_xfer_len = 0;-	dcmd->opcode = opcode;+	dcmd->opcode = MR_DCMD_CTRL_SHUTDOWN;  	megasas_issue_blocked_cmd(instance, cmd); @@ -2791,136 +3052,6 @@ static void megasas_shutdown_controller( }  /**- * megasas_suspend -	driver suspend entry point- * @pdev:		PCI device structure- * @state:				- */-static int __devinit-megasas_suspend(struct pci_dev *pdev, pm_message_t state)-{-	struct Scsi_Host *host;-	struct megasas_instance *instance;--	instance = pci_get_drvdata(pdev);-	host = instance->host;--	megasas_flush_cache(instance);-	megasas_shutdown_controller(instance, MR_DCMD_HIBERNATE_SHUTDOWN);-	tasklet_kill(&instance->isr_tasklet);--	pci_set_drvdata(instance->pdev, instance); -	instance->instancet->disable_intr(instance->reg_set);-	free_irq(instance->pdev->irq, instance);--	scsi_host_put(host);--	pci_save_state(pdev);-	pci_disable_device(pdev);--	pci_set_power_state(pdev, pci_choose_state(pdev, state));--	return 0;-}--/**- * megasas_resume-	driver resume entry point- * @pdev:		PCI device structure- */-static int __devinit-megasas_resume(struct pci_dev *pdev)-{-	int rval;-	struct Scsi_Host *host;-	struct megasas_instance *instance;-	-	instance = pci_get_drvdata(pdev);-	host = instance->host;-	pci_set_power_state(pdev, PCI_D0);-	pci_enable_wake(pdev, PCI_D0, 0);-	pci_restore_state(pdev);--	/*-	 * PCI prepping: enable device set bus mastering and dma mask-	 */-	rval = pci_enable_device(pdev);--	if (rval) {-		printk(KERN_INFO "megasas: Enable device failed\n");-		return rval;-	}--	pci_set_master(pdev);--	if (megasas_set_dma_mask(pdev))-		goto fail_set_dma_mask;--	/*-	 * Initialize MFI Firmware-	 */--	*instance->producer = 0;-	*instance->consumer = 0;--	atomic_set(&instance->fw_outstanding,0);--	/*-	 * We expect the FW state to be READY-	 */-	if (megasas_transition_to_ready(instance))-		goto fail_ready_state;--	if (megasas_issue_init_mfi(instance))-		goto fail_init_mfi;--	tasklet_init(&instance->isr_tasklet, megasas_complete_cmd_dpc,-                        (unsigned long)instance);	-	/*-	 * Register IRQ-	 */-	if (request_irq(pdev->irq, megasas_isr, IRQF_SHARED,-		"megasas",instance)) {-		printk(KERN_DEBUG "megasas: Failed to register IRQ\n");-		goto fail_irq;-	}--	instance->instancet->enable_intr(instance->reg_set);--	/*-	 * Store instance in PCI softstate-	 */-	pci_set_drvdata(pdev, instance);--	/*-	 * Initiate AEN (Asynchronous Event Notification)-	 */-	if (megasas_start_aen(instance))-		printk(KERN_ERR "megasas: Start AEN failed\n");-	-	return 0;	-	-      fail_irq:-      fail_init_mfi:--	if (instance->evt_detail)-		pci_free_consistent(pdev, sizeof(struct megasas_evt_detail),-				    instance->evt_detail,-				    instance->evt_detail_h);--	if (instance->producer)-		pci_free_consistent(pdev, sizeof(u32), instance->producer,-				    instance->producer_h);-	if (instance->consumer)-		pci_free_consistent(pdev, sizeof(u32), instance->consumer,-				    instance->consumer_h);-	scsi_host_put(host);-      fail_set_dma_mask:-      fail_ready_state:-	pci_disable_device(pdev);--	return -ENODEV;-}--/**  * megasas_detach_one -	PCI hot"un"plug entry point  * @pdev:		PCI device structure  */@@ -2933,11 +3064,12 @@ static void megasas_detach_one(struct pc 	instance = pci_get_drvdata(pdev); 	host = instance->host; -	sysfs_remove_bin_file(&host->shost_classdev.kobj, &sysfs_max_sectors_attr);-	scsi_remove_host(instance->host);+#if CONFIG_PROC_FS+	if (megasas_proc_root && instance->hba_proc_dir)+		megasas_remove_proc_entry(instance);+#endif 	megasas_flush_cache(instance);-	megasas_shutdown_controller(instance, MR_DCMD_CTRL_SHUTDOWN);-	tasklet_kill(&instance->isr_tasklet);+	megasas_shutdown_controller(instance);  	/* 	 * Take the instance off the instance array. Note that we will not@@ -2959,6 +3091,8 @@ static void megasas_detach_one(struct pc 	free_irq(instance->pdev->irq, instance);  	megasas_release_mfi(instance);+	+	megasas_free_ioctl_mem_pools(instance); /* for-ioctl: free the mem pool */  	pci_free_consistent(pdev, sizeof(struct megasas_evt_detail), 			    instance->evt_detail, instance->evt_detail_h);@@ -2969,7 +3103,7 @@ static void megasas_detach_one(struct pc 	pci_free_consistent(pdev, sizeof(u32), instance->consumer, 			    instance->consumer_h); -	scsi_host_put(host);+	scsi_unregister(host);  	pci_set_drvdata(pdev, NULL); @@ -2978,14 +3112,12 @@ static void megasas_detach_one(struct pc 	return; } -/**- * megasas_shutdown -	Shutdown entry point- * @device:		Generic device structure- */-static void megasas_shutdown(struct pci_dev *pdev)+static int megasas_release(struct Scsi_Host *host) {-	struct megasas_instance *instance = pci_get_drvdata(pdev);-	megasas_flush_cache(instance);+	if (host->pci_dev)+		megasas_detach_one(host->pci_dev);++	return 0; }  /**@@ -2996,9 +3128,6 @@ static int megasas_mgmt_open(struct inod 	/* 	 * Allow only those users with admin rights 	 */-	if (!capable(CAP_SYS_ADMIN))-		return -EACCES;- 	return 0; } @@ -3023,11 +3152,11 @@ static int megasas_mgmt_fasync(int fd, s { 	int rc; -	mutex_lock(&megasas_async_queue_mutex);+	down(&megasas_async_queue_mutex);  	rc = fasync_helper(fd, filep, mode, &megasas_async_queue); -	mutex_unlock(&megasas_async_queue_mutex);+	up(&megasas_async_queue_mutex);  	if (rc >= 0) { 		/* For sanity check when we get ioctl */@@ -3059,6 +3188,7 @@ megasas_mgmt_fw_ioctl(struct megasas_ins 	dma_addr_t sense_handle; 	u32 *sense_ptr; 	unsigned long *sense_buff;+	u8 from_pool=0;  	memset(kbuff_arr, 0, sizeof(kbuff_arr)); @@ -3093,19 +3223,32 @@ megasas_mgmt_fw_ioctl(struct megasas_ins 	 */ 	kern_sge32 = (struct megasas_sge32 *) 	    ((unsigned long)cmd->frame + ioc->sgl_off);-+	/*+	 * Check if we have buffer to use from our mem_pool+	 * If we donot have then try to allocate new buffer+	 */+	if(!megasas_get_buff_for_sge(ioc,instance,cmd))+		from_pool=1; 	/* 	 * For each user buffer, create a mirror buffer and copy in 	 */ 	for (i = 0; i < ioc->sge_count; i++) {-		kbuff_arr[i] = dma_alloc_coherent(&instance->pdev->dev,++		if (from_pool) {+			kbuff_arr[i] = cmd->ioctl_mem[i]->vaddr;+			buf_handle = cmd->ioctl_mem[i]->buf_handle;+		} else {++			kbuff_arr[i] = pci_alloc_consistent(instance->pdev, 						    ioc->sgl[i].iov_len,-						    &buf_handle, GFP_KERNEL);-		if (!kbuff_arr[i]) {-			printk(KERN_DEBUG "megasas: Failed to alloc "-			       "kernel SGL buffer for IOCTL \n");-			error = -ENOMEM;-			goto out;+						    &buf_handle);+			if (!kbuff_arr[i]) {+				printk(KERN_DEBUG "megasas: Failed to alloc "+				       "kernel SGL buffer for IOCTL \n");+				error = -ENOMEM;+				goto out;+			}+		 		}  		/*@@ -3127,8 +3270,8 @@ megasas_mgmt_fw_ioctl(struct megasas_ins 	}  	if (ioc->sense_len) {-		sense = dma_alloc_coherent(&instance->pdev->dev, ioc->sense_len,-					     &sense_handle, GFP_KERNEL);+		sense = pci_alloc_consistent(instance->pdev, ioc->sense_len,+					     &sense_handle); 		if (!sense) { 			error = -ENOMEM; 			goto out;@@ -3166,16 +3309,18 @@ megasas_mgmt_fw_ioctl(struct megasas_ins 		 * sense_buff points to the location that has the user 		 * sense buffer address 		 */-		sense_buff = (unsigned long *) ((unsigned long)ioc->frame.raw +++                sense_buff = (unsigned long *) ((unsigned long)ioc->frame.raw + 					ioc->sense_off); 		sense_ptr = (u32 *) ((unsigned long)ioc->frame.raw + 					ioc->sense_off); #if defined(__ia64__) 		if (copy_to_user((void __user *)((unsigned long)(*sense_buff)),+                                 sense, ioc->sense_len)) { #else 		if (copy_to_user((void __user *)((unsigned long)(*sense_ptr)),-#endif                                  sense, ioc->sense_len)) {+#endif                         printk(KERN_ERR "megasas: Failed to copy out to user"                                "sense data\n");                         error = -EFAULT;@@ -3194,20 +3339,45 @@ megasas_mgmt_fw_ioctl(struct megasas_ins        out: 	if (sense) {-		dma_free_coherent(&instance->pdev->dev, ioc->sense_len,+		pci_free_consistent(instance->pdev, ioc->sense_len, 				    sense, sense_handle); 	}-+	 	for (i = 0; i < ioc->sge_count && kbuff_arr[i]; i++) {-		dma_free_coherent(&instance->pdev->dev,-				    kern_sge32[i].length,-				    kbuff_arr[i], kern_sge32[i].phys_addr);+		if (from_pool) {+			/* Return to the mem pool */+			if ((struct megasas_ioctl_mm *)cmd->ioctl_mem[i]) {+				megasas_return_ioctl_mem(instance, +					(struct megasas_ioctl_mm *)cmd->ioctl_mem[i], +					cmd->ioctl_mem_pool_index[i]);+				cmd->ioctl_mem_pool_index[i]=0xff;+				cmd->ioctl_mem[i]=NULL;+			}+		} else {+			pci_free_consistent(instance->pdev,+					kern_sge32[i].length,+					kbuff_arr[i], kern_sge32[i].phys_addr);+		} 	}  	megasas_return_cmd(instance, cmd); 	return error; } 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -