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

📄 rhel3_diskdump.patch

📁 最新的Megaraid SAS卡驱动源代码
💻 PATCH
字号:
diff -uprN rhel3/megaraid_sas.c rhel3_dump/megaraid_sas.c--- rhel3/megaraid_sas.c	2007-10-15 00:36:01.000000000 -0700+++ rhel3_dump/megaraid_sas.c	2007-10-15 00:44:09.000000000 -0700@@ -43,6 +43,7 @@ #include <linux/proc_fs.h> #include <linux/blk.h> #include <linux/notifier.h>+#include <linux/diskdump.h>  #if defined (__x86_64__) #include <asm/ioctl32.h>@@ -51,6 +52,7 @@ #include "scsi.h" #include "hosts.h" #include "sd.h"+#include "scsi_dump.h"  #include "megaraid_sas.h" @@ -66,7 +68,8 @@ static unsigned int fast_load = 0; module_param(fast_load, int, 0); MODULE_PARM_DESC(fast_load,-	"megasas: Faster loading of the driver, skips physical devices!  (default=0)");+	"megasas: Faster loading of the driver, skips physical devices! \+	 (default=0)");  /*  * Number of sectors per IO command@@ -85,6 +88,7 @@ module_param(cmd_per_lun, int, 0); MODULE_PARM_DESC(cmd_per_lun, 	"Maximum number of commands per logical unit (default=128)"); + MODULE_LICENSE("GPL"); #ifdef MODULE_VERSION MODULE_VERSION(MEGASAS_VERSION);@@ -99,6 +103,12 @@ static void megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, 		     u8 alt_status); +static void+megasas_deplete_reply_queue(struct megasas_instance *instance, u8 alt_status);+static irqreturn_t megasas_isr(int irq, void *devp, struct pt_regs *regs);+static void megasas_flush_cache(struct megasas_instance *instance);+static int megasas_issue_polled(struct megasas_instance *instance, struct megasas_cmd *cmd);+ /*  * PCI ID table for all supported controllers  */@@ -167,6 +177,14 @@ static inline unsigned long msecs_to_jif  static void msleep(unsigned long msecs) {+#if defined(CONFIG_DISKDUMP) || defined(CONFIG_DISKDUMP_MODULE)+	if (unlikely(crashdump_mode())) {+		for (; msecs > 1000; msecs -= 1000)+			udelay(1000);+		udelay(msecs);+		return;+	}+#endif 	set_current_state(TASK_UNINTERRUPTIBLE); 	schedule_timeout(msecs_to_jiffies(msecs) + 1); }@@ -259,8 +277,9 @@ static void megasas_create_proc_entry(st 			       megasas_proc_show_bus_devfn, instance);  	create_proc_read_entry("max_sector", S_IRUSR | S_IFREG,-			       instance->hba_proc_dir,-			       megasas_proc_show_max_sectors, NULL);+			   instance->hba_proc_dir,+			   megasas_proc_show_max_sectors, NULL);+  } @@ -748,7 +767,7 @@ u32 megasas_get_frame_count(u8 sge_count 		frame_count = 8; 	return frame_count; }-+		 /**  * megasas_build_dcdb -	Prepares a direct cdb (DCDB) command  * @instance:		Adapter soft state@@ -1064,14 +1083,13 @@ megasas_queue_command(struct scsi_cmnd * 	switch (scmd->cmnd[0]) { 		case SYNCHRONIZE_CACHE: #if defined(CONFIG_DISKDUMP) || defined(CONFIG_DISKDUMP_MODULE)-			if (crashdump_mode())+			if (!crashdump_mode()) #endif 			{ 				scmd->result = DID_OK << 16; 				goto out_done; 			} 	}- 	/* If FW is busy donot accept any more cmds */ 	if(instance->is_busy){ 		sec = (jiffies - instance->last_time) / HZ;@@ -1091,13 +1109,29 @@ megasas_queue_command(struct scsi_cmnd * 	cmd = megasas_get_cmd(instance); 	if (!cmd) 		return SCSI_MLQUEUE_HOST_BUSY;+#if defined(CONFIG_DISKDUMP) || defined(CONFIG_DISKDUMP_MODULE)+	if (MEGASAS_IS_LOGICAL(scmd)){+		switch (scmd->cmnd[0]) {+			case SYNCHRONIZE_CACHE:+				if (crashdump_mode()) +					megasas_flush_cache(instance);+			case REQUEST_SENSE:+			case MODE_SELECT:+			case MODE_SENSE:+				if (crashdump_mode()) {+					scmd->result = (DID_OK << 16);+					goto out_done;+				}+		}+	}+#endif  	/* 	 * Logical drive command 	 */ 	if (megasas_is_ldio(scmd)) 		frame_count = megasas_build_ldio(instance, scmd, cmd);-	else +	else 		frame_count = megasas_build_dcdb(instance, scmd, cmd);  	if (!frame_count)@@ -1184,6 +1218,14 @@ static int megasas_wait_for_outstanding( 			 */ 			megasas_complete_cmd_q(instance, DID_OK); 		}+#if defined(CONFIG_DISKDUMP) || defined(CONFIG_DISKDUMP_MODULE)+		/*+		* In crash dump mode cannot complete cmds in interrupt context  +		* Complete cmds from here+		*/+		if(crashdump_mode())+			megasas_deplete_reply_queue(instance, DID_OK);+#endif  		msleep(1000); 	}@@ -1296,6 +1338,63 @@ megasas_service_aen(struct megasas_insta 	megasas_return_cmd(instance, cmd); } +#if defined(CONFIG_DISKDUMP) || defined(CONFIG_DISKDUMP_MODULE)+static int+megasas_diskdump_sanity_check(struct scsi_device *device)+{+        struct megasas_instance *instance;++	instance = (struct megasas_instance *)device->host->hostdata;++        if (!instance)+                return -ENXIO;++        if (spin_is_locked(&instance->cmd_pool_lock))+                return -EBUSY;+        return 0;+}++static void+megasas_diskdump_poll(struct scsi_device *device)+{+        struct megasas_instance *instance;++	instance = (struct megasas_instance *)device->host->hostdata;++        if (!instance)+                return ;++	megasas_isr(0,instance, NULL);+}+static struct scsi_dump_ops megasas_dump_ops = {+	.sanity_check	= megasas_diskdump_sanity_check,+	.poll		= megasas_diskdump_poll,+	.no_write_cache_enable = 1+};+/*+ * Scsi host template for megaraid_sas driver (diskdump)+ */+static Scsi_Host_Template_dump megasas_template_dump = {++	.hostt = {						+		.name = "MegaRAID SAS",+		.proc_name = "megaraid_sas",+		.info = megasas_info,+		.queuecommand = megasas_queue_command,+		.eh_device_reset_handler = megasas_reset_device,+		.eh_bus_reset_handler = megasas_reset_bus_host,+		.eh_host_reset_handler = megasas_reset_bus_host,+		.use_clustering = ENABLE_CLUSTERING,+		.use_new_eh_code = 1,+		.highmem_io = 1,+		.vary_io = 1,+		.disk_dump = 1,		+		},							+	.dump_ops = &megasas_dump_ops,+};+#define megasas_template		(megasas_template_dump.hostt)++#else /*  * Scsi host template for megaraid_sas driver  */@@ -1314,6 +1413,8 @@ static Scsi_Host_Template megasas_templa 	.vary_io = 1, }; +#endif+ /**  * megasas_complete_int_cmd -	Completes an internal command  * @instance:			Adapter soft state@@ -1554,12 +1655,12 @@ megasas_complete_cmd(struct megasas_inst  * 					SCSI mid-layer instead of the status  * 					returned by the FW  */-static inline void+static void megasas_deplete_reply_queue(struct megasas_instance *instance, u8 alt_status) { 	/* 	 * Check if it is our interrupt-	 * Clear the interrupt +	 * Clear the interrupt 	 */ 	if (instance->instancet->clear_intr(instance->reg_set)) 		return IRQ_NONE;@@ -2362,9 +2463,9 @@ static int megasas_init_mfi(struct megas 		tmp_sectors = (max_sectors_1 < max_sectors_2) 		    ? max_sectors_1 : max_sectors_2; 	}- + 	instance->max_sectors_per_req = instance->max_num_sge *-		    PAGE_SIZE / 512;+ 		    PAGE_SIZE / 512; 	if (tmp_sectors && (instance->max_sectors_per_req > tmp_sectors)) 		instance->max_sectors_per_req = tmp_sectors; @@ -2644,9 +2745,10 @@ static int megasas_io_attach(struct mega 		instance->max_sectors_per_req = max_sector; 	else { 		if (max_sector)-			printk(KERN_INFO "megasas: max_sectors should be > 0 and"+			printk(KERN_INFO "megasas: max_sector should be > 0 and" 			 	"<= %d\n",instance->max_sectors_per_req); 	}+ 	max_sector = instance->max_sectors_per_req; 	host->max_sectors = instance->max_sectors_per_req; @@ -2659,10 +2761,11 @@ static int megasas_io_attach(struct mega 	else 		printk(KERN_INFO "megasas: cmd_per_lun should be > 0 and" 			 	"<= %d\n",MEGASAS_DEFAULT_CMD_PER_LUN);-	cmd_per_lun = instance->cmd_per_lun;	+		+	cmd_per_lun = instance->cmd_per_lun; 	host->cmd_per_lun = instance->cmd_per_lun; -	printk(KERN_DEBUG "megasas: max_sectors : 0x%x, cmd_per_lun : 0x%x\n",+	printk(KERN_DEBUG "megasas: max_sector : 0x%x, cmd_per_lun : 0x%x\n", 			instance->max_sectors_per_req, instance->cmd_per_lun); 	 	host->max_channel = MEGASAS_MAX_CHANNELS - 1;@@ -2683,6 +2786,7 @@ static int megasas_io_attach(struct mega 	 */ 	scsi_scan_host(host); 	return 0;+ }  /**@@ -2876,7 +2980,7 @@ megasas_probe_one(struct pci_dev *pdev,        fail_init_mfi:       fail_alloc_dma_buf: 	/* Free the ioctl mem pool */-	megasas_free_ioctl_mem_pools(instance); +	megasas_free_ioctl_mem_pools(instance); /* for-ioctl: free the mem pool */ 	if (instance->evt_detail) 		pci_free_consistent(pdev, sizeof(struct megasas_evt_detail), 				    instance->evt_detail,@@ -2924,7 +3028,14 @@ static void megasas_flush_cache(struct m 	dcmd->opcode = MR_DCMD_CTRL_CACHE_FLUSH; 	dcmd->mbox.b[0] = MR_FLUSH_CTRL_CACHE | MR_FLUSH_DISK_CACHE; -	megasas_issue_blocked_cmd(instance, cmd);+#if defined(CONFIG_DISKDUMP) || defined(CONFIG_DISKDUMP_MODULE)+	if (crashdump_mode())+		megasas_issue_polled(instance, cmd);+	else+		megasas_issue_blocked_cmd(instance, cmd);+#else+ 	megasas_issue_blocked_cmd(instance, cmd);+#endif  	megasas_return_cmd(instance, cmd); @@ -3038,9 +3149,9 @@ static void megasas_detach_one(struct pc 	free_irq(instance->pdev->irq, instance);  	megasas_release_mfi(instance);-+	 	/* Free IOCTL mem pool */-	megasas_free_ioctl_mem_pools(instance); +	megasas_free_ioctl_mem_pools(instance);  	pci_free_consistent(pdev, sizeof(struct megasas_evt_detail), 			    instance->evt_detail, instance->evt_detail_h);@@ -3178,6 +3289,7 @@ megasas_mgmt_fw_ioctl(struct megasas_ins 	 * For each user buffer, create a mirror buffer and copy in 	 */ 	for (i = 0; i < ioc->sge_count; i++) {+ 		if (from_pool) { 			kbuff_arr[i] = cmd->ioctl_mem[i]->vaddr; 			buf_handle = cmd->ioctl_mem[i]->buf_handle;@@ -3251,6 +3363,7 @@ 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 + 					ioc->sense_off); 		sense_ptr = (u32 *) ((unsigned long)ioc->frame.raw +@@ -3281,7 +3394,6 @@ megasas_mgmt_fw_ioctl(struct megasas_ins 	} 	 	for (i = 0; i < ioc->sge_count && kbuff_arr[i]; i++) {- 		if (from_pool) { 			/* Return to the mem pool */ 			if ((struct megasas_ioctl_mm *)cmd->ioctl_mem[i]) {@@ -3426,7 +3538,6 @@ megasas_convert_compat_iocpacket(struct  	} } - static int  megasas_mgmt_compat_ioctl_fw(struct file *file, unsigned long arg) {@@ -3577,6 +3688,7 @@ static int __init megasas_init(void) 					   megasas_proc_show_dbg_lvl, 					   megasas_proc_get_dbg_lvl); + 		megasas_proc_hba_map = proc_mkdir("hba_map", megasas_proc_root); 	} #endifdiff -uprN rhel3/megaraid_sas.h rhel3_dump/megaraid_sas.h--- rhel3/megaraid_sas.h	2007-10-13 20:39:15.000000000 -0700+++ rhel3_dump/megaraid_sas.h	2007-10-13 20:41:00.000000000 -0700@@ -75,7 +75,7 @@ typedef void irqreturn_t;  * "message frames"  */ -/*+/**  * FW posts its state in upper 4 bits of outbound_msg_0 register  */ #define MFI_STATE_MASK				0xF0000000@@ -541,7 +541,7 @@ struct megasas_ctrl_info { 	/* 	 * Define ECC single-bit-error bucket information 	 */-+	 	u8 ecc_bucket_count; 	u8 reserved_2[11]; @@ -577,8 +577,8 @@ struct megasas_ctrl_info { #define MEGASAS_DBG_LVL				1  /* - * For ioctl memory manager- */+* For memory manager+*/  #define MAX_IOCTL_MEM_POOL			3 #define MEGASAS_INIT_IOCTL_MEM_SIZE		4096

⌨️ 快捷键说明

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