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

📄 rhel4.patch

📁 最新的Megaraid SAS卡驱动源代码
💻 PATCH
📖 第 1 页 / 共 3 页
字号:
diff -uprN base/megaraid_sas.c rhel4/megaraid_sas.c--- base/megaraid_sas.c	2007-10-13 20:49:29.000000000 -0700+++ rhel4/megaraid_sas.c	2007-10-13 20:45:22.000000000 -0700@@ -9,7 +9,7 @@  *	   as published by the Free Software Foundation; either version  *	   2 of the License, or (at your option) any later version.  *- * FILE		: megaraid_sas.c+ * FILE		: megaraid_sas.c   * Version	: v00.00.03.16  *  * Authors:@@ -28,6 +28,7 @@ #include <linux/types.h> #include <linux/pci.h> #include <linux/list.h>+#include <linux/version.h> #include <linux/moduleparam.h> #include <linux/module.h> #include <linux/spinlock.h>@@ -36,9 +37,10 @@ #include <linux/uio.h> #include <asm/uaccess.h> #include <linux/fs.h>-#include <linux/compat.h>+#include <linux/ioctl32.h> #include <linux/blkdev.h>-#include <linux/mutex.h>+#include <linux/compat.h>+#include <linux/diskdump.h>  #include <scsi/scsi.h> #include <scsi/scsi_cmnd.h>@@ -47,7 +49,7 @@ #include "megaraid_sas.h"  /*- * Modules parameters+ * modules parameters for driver  */  /*@@ -58,8 +60,7 @@ static unsigned int fast_load = 0; module_param_named(fast_load, 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@@ -84,6 +85,17 @@ MODULE_AUTHOR("megaraidlinux@lsi.com"); MODULE_DESCRIPTION("LSI Logic MegaRAID SAS Driver");  /*+ * diskdump helper function. We can't call msleep() or mdelay() while dumping.+ */+static void megasas_msleep(unsigned long ms)+{+	if(unlikely(crashdump_mode())) {+		diskdump_mdelay(ms);+	} else+		msleep(ms);+}++/*  * PCI ID table for all supported controllers  */ static struct pci_device_id megasas_pci_table[] = {@@ -104,20 +116,24 @@ MODULE_DEVICE_TABLE(pci, megasas_pci_tab static int megasas_mgmt_majorno; static struct megasas_mgmt_info megasas_mgmt_info; static struct fasync_struct *megasas_async_queue;-static DEFINE_MUTEX(megasas_async_queue_mutex);-+static DECLARE_MUTEX(megasas_async_queue_mutex); static u32 megasas_dbg_lvl;  static void megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, 		     u8 alt_status);+static int+megasas_deplete_reply_queue(struct megasas_instance *instance, u8 alt_status);+static void megasas_flush_cache(struct megasas_instance *instance);+static irqreturn_t megasas_isr(int irq, void *devp, struct pt_regs *regs);+ /**  * megasas_get_cmd -	Get a command from the free pool  * @instance:		Adapter soft state  *  * Returns a free command from the pool  */-static struct megasas_cmd *megasas_get_cmd(struct megasas_instance+static inline struct megasas_cmd *megasas_get_cmd(struct megasas_instance 						  *instance) { 	unsigned long flags;@@ -155,7 +171,6 @@ megasas_return_cmd(struct megasas_instan 	spin_unlock_irqrestore(&instance->cmd_pool_lock, flags); } - /** *	The following functions are defined for xscale  *	(deviceid : 1064R, PERC5) controllers@@ -175,13 +190,13 @@ megasas_enable_intr_xscale(struct megasa }  /**- * megasas_disable_intr_xscale -Disables interrupt+ * megasas_disable_intr_xscale -Disable interrupt  * @regs:			MFI register set  */ static inline void megasas_disable_intr_xscale(struct megasas_register_set __iomem * regs) {-	u32 mask = 0x1f;+	u32 mask = 0x1f;  	writel(mask, &regs->outbound_intr_mask); 	/* Dummy readl to force pci flush */ 	readl(&regs->outbound_intr_mask);@@ -196,6 +211,7 @@ megasas_read_fw_status_reg_xscale(struct { 	return readl(&(regs)->outbound_msg_0); }+ /**  * megasas_clear_interrupt_xscale -	Check & clear interrupt  * @regs:				MFI register set@@ -269,13 +285,13 @@ megasas_enable_intr_ppc(struct megasas_r }  /**- * megasas_disable_intr_ppc -	Disables interrupt+ * megasas_disable_intr_ppc -	Disable interrupt  * @regs:			MFI register set  */ static inline void megasas_disable_intr_ppc(struct megasas_register_set __iomem * regs) {-	u32 mask = 0xFFFFFFFF;+	u32 mask = 0xFFFFFFFF;  	writel(mask, &regs->outbound_intr_mask); 	/* Dummy readl to force pci flush */ 	readl(&regs->outbound_intr_mask);@@ -370,7 +386,7 @@ megasas_issue_polled(struct megasas_inst 	 */ 	for (i = 0; (i < msecs) && (frame_hdr->cmd_status == 0xff); i++) { 		rmb();-		msleep(1);+		megasas_msleep(1); 	}  	if (frame_hdr->cmd_status == 0xff)@@ -460,7 +476,7 @@ megasas_issue_blocked_abort_cmd(struct m  * If successful, this function returns the number of SG elements. Otherwise,  * it returnes -1.  */-static int+static inline int megasas_make_sgl32(struct megasas_instance *instance, struct scsi_cmnd *scp, 		   union megasas_sgl *mfi_sgl) {@@ -508,7 +524,7 @@ megasas_make_sgl32(struct megasas_instan  * If successful, this function returns the number of SG elements. Otherwise,  * it returnes -1.  */-static int+static inline int megasas_make_sgl64(struct megasas_instance *instance, struct scsi_cmnd *scp, 		   union megasas_sgl *mfi_sgl) {@@ -549,13 +565,13 @@ megasas_make_sgl64(struct megasas_instan }   /**- * megasas_get_frame_count - Computes the number of frames+ * megasas_get_frame_count - Computes the number of frames   * @sge_count		: number of sg elements  *  * Returns the number of frames required for numnber of sge's (sge_count)  */ -static u32 megasas_get_frame_count(u8 sge_count)+u32 megasas_get_frame_count(u8 sge_count) { 	int num_cnt; 	int sge_bytes;@@ -566,7 +582,7 @@ static u32 megasas_get_frame_count(u8 sg 	    sizeof(struct megasas_sge32);  	/*-	* Main frame can contain 2 SGEs for 64-bit SGLs and+	* Main frame can contain 2 SGEs for 64-bit SGLs and  	* 3 SGEs for 32-bit SGLs 	*/ 	if (IS_DMA64)@@ -587,7 +603,7 @@ static u32 megasas_get_frame_count(u8 sg 		frame_count = 8; 	return frame_count; }-+		 /**  * megasas_build_dcdb -	Prepares a direct cdb (DCDB) command  * @instance:		Adapter soft state@@ -597,7 +613,7 @@ static u32 megasas_get_frame_count(u8 sg  * This function prepares CDB commands. These are typcially pass-through  * commands to the devices.  */-static int+static inline int megasas_build_dcdb(struct megasas_instance *instance, struct scsi_cmnd *scp, 		   struct megasas_cmd *cmd) {@@ -879,28 +895,36 @@ megasas_queue_command(struct scsi_cmnd *  	instance = (struct megasas_instance *) 	    scmd->device->host->hostdata;--	/* Don't process if we have already declared adapter dead */-	if (instance->hw_crit_error)-		return SCSI_MLQUEUE_HOST_BUSY;- 	scmd->scsi_done = done; 	scmd->result = 0; +	/*Don't process if we have already declared adapter dead*/+	if(instance->hw_crit_error)+		return SCSI_MLQUEUE_HOST_BUSY;+ 	if (MEGASAS_IS_LOGICAL(scmd) && 	    (scmd->device->id >= MEGASAS_MAX_LD || scmd->device->lun)) { 		scmd->result = DID_BAD_TARGET << 16; 		goto out_done; 	} -	switch (scmd->cmnd[0]) {-	case SYNCHRONIZE_CACHE:-		/*-		 * FW takes care of flush cache on its own-		 * No need to send it down-		 */-		scmd->result = DID_OK << 16;-		goto out_done;+	if (MEGASAS_IS_LOGICAL(scmd)) {+		switch (scmd->cmnd[0]) {+			case SYNCHRONIZE_CACHE:+				if (crashdump_mode()) +					megasas_flush_cache(instance);+				else{+					scmd->result = (DID_OK << 16);+					goto out_done;+				}+			case REQUEST_SENSE:+			case MODE_SELECT:+			case MODE_SENSE:+				if (crashdump_mode()) {+					scmd->result = (DID_OK << 16);+					goto out_done;+				}+		} 	}  	cmd = megasas_get_cmd(instance);@@ -920,13 +944,15 @@ megasas_queue_command(struct scsi_cmnd *  	cmd->scmd = scmd; 	scmd->SCp.ptr = (char *)cmd;+	scmd->SCp.sent_command = jiffies;  	/* 	 * Issue the command to the FW 	 */ 	atomic_inc(&instance->fw_outstanding); -	instance->instancet->fire_cmd(cmd->frame_phys_addr ,cmd->frame_count-1,instance->reg_set);+	instance->instancet->fire_cmd(cmd->frame_phys_addr ,+			cmd->frame_count-1,instance->reg_set);  	return 0; @@ -937,33 +963,13 @@ megasas_queue_command(struct scsi_cmnd * 	return 0; } -static int megasas_slave_configure(struct scsi_device *sdev)-{-	/*-	 * Don't export physical disk devices to the disk driver.-	 *-	 * FIXME: Currently we don't export them to the midlayer at all.-	 * 	  That will be fixed once LSI engineers have audited the-	 * 	  firmware for possible issues.-	 */-	if (sdev->channel < MEGASAS_MAX_PD_CHANNELS && sdev->type == TYPE_DISK)-		return -ENXIO;--	/*-	 * The RAID firmware may require extended timeouts.-	 */-	if (sdev->channel >= MEGASAS_MAX_PD_CHANNELS)-		sdev->timeout = MEGASAS_DEFAULT_CMD_TIMEOUT * HZ;-	return 0;-}- /**  * megasas_complete_cmd_dpc	 -	Returns FW's controller structure  * @instance_addr:			Address of adapter soft state  *  * Tasklet to complete cmds  */-static void megasas_complete_cmd_dpc(unsigned long instance_addr)+void megasas_complete_cmd_dpc(unsigned long instance_addr) { 	u32 producer; 	u32 consumer;@@ -995,8 +1001,22 @@ static void megasas_complete_cmd_dpc(uns 	}  	*instance->consumer = producer;- 	spin_unlock_irqrestore(&instance->completion_lock, flags);++	/*+	 * Check if we can restore can_queue+	 */+	if (instance->flag & MEGASAS_FW_BUSY+		&& time_after(jiffies, instance->last_time + 5 * HZ)+		&& atomic_read(&instance->fw_outstanding) < 17) {++		spin_lock_irqsave(instance->host->host_lock, flags);+		instance->flag &= ~MEGASAS_FW_BUSY;+		instance->host->can_queue =+				instance->max_fw_cmds - MEGASAS_INT_CMDS;++		spin_unlock_irqrestore(instance->host->host_lock, flags);+	} }  /**@@ -1029,7 +1049,16 @@ static int megasas_wait_for_outstanding( 			megasas_complete_cmd_dpc((unsigned long)instance); 		} -		msleep(1000);+		/*+		* In crash dump mode cannot complete cmds in interrupt context+		* Complete cmds from here+		*/+		if (crashdump_mode()) {+			tasklet_schedule(&instance->isr_tasklet);+			diskdump_update();+		}+		+		megasas_msleep(1000); 	}  	if (atomic_read(&instance->fw_outstanding)) {@@ -1062,8 +1091,9 @@ static int megasas_generic_reset(struct   	instance = (struct megasas_instance *)scmd->device->host->hostdata; -	scmd_printk(KERN_NOTICE, scmd, "megasas: RESET -%ld cmd=%x retries=%x\n",-		 scmd->serial_number, scmd->cmnd[0], scmd->retries);+	printk(KERN_NOTICE "megasas: RESET -%ld cmd=%x <c=%d t=%d l=%d> retries=%x\n",+	       scmd->serial_number, scmd->cmnd[0], scmd->device->channel,+	       scmd->device->id, scmd->device->lun, scmd->retries);  	if (instance->hw_crit_error) { 		printk(KERN_ERR "megasas: cannot recover from previous reset "@@ -1071,12 +1101,17 @@ static int megasas_generic_reset(struct  		return FAILED; 	} +	spin_unlock(scmd->device->host->host_lock);+ 	ret_val = megasas_wait_for_outstanding(instance);+ 	if (ret_val == SUCCESS) 		printk(KERN_NOTICE "megasas: reset successful \n"); 	else 		printk(KERN_ERR "megasas: failed to do reset\n"); +	spin_lock(scmd->device->host->host_lock);+ 	return ret_val; } @@ -1094,7 +1129,7 @@ scsi_eh_timer_return megasas_reset_timer 	struct megasas_instance *instance; 	unsigned long flags; -	if (time_after(jiffies, scmd->jiffies_at_alloc ++	if (time_after(jiffies, (unsigned long)scmd->SCp.sent_command + 				(MEGASAS_DEFAULT_CMD_TIMEOUT * 2) * HZ)) { 		return EH_NOT_HANDLED; 	}@@ -1213,6 +1248,53 @@ megasas_service_aen(struct megasas_insta 	megasas_return_cmd(instance, cmd); } +static int megasas_slave_configure(struct scsi_device *sdev)+{+	/*+	* The RAID firmware may require extended timeouts+	*/+	if(sdev->channel >= MEGASAS_MAX_PD_CHANNELS)+		sdev->timeout = MEGASAS_DEFAULT_CMD_TIMEOUT * HZ;+	return 0;+}++/**+ * megasas_diskdump_sanity_check - 	Entry point for diskdump+ */+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;+}++/**+ * megasas_diskdump_poll -	Interrupts are disabled during diskdump+ *				so this fn is called by diskdump driver to+ *				complete IO+ */

⌨️ 快捷键说明

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