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

📄 sles9-sp2.patch

📁 最新的Megaraid SAS卡驱动源代码
💻 PATCH
📖 第 1 页 / 共 3 页
字号:
diff -uprN base/megaraid_sas.c sles9-sp2/megaraid_sas.c--- base/megaraid_sas.c	2007-10-13 20:49:29.000000000 -0700+++ sles9-sp2/megaraid_sas.c	2007-10-13 20:46:04.000000000 -0700@@ -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,9 @@ #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 <scsi/scsi.h> #include <scsi/scsi_cmnd.h>@@ -78,6 +79,7 @@ module_param_named(cmd_per_lun, cmd_per_ MODULE_PARM_DESC(cmd_per_lun, 	"Maximum number of commands per logical unit (default=128)"); + MODULE_LICENSE("GPL"); MODULE_VERSION(MEGASAS_VERSION); MODULE_AUTHOR("megaraidlinux@lsi.com");@@ -104,20 +106,20 @@ 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);+ /**  * 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;@@ -181,7 +183,7 @@ megasas_enable_intr_xscale(struct megasa 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 +198,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@@ -275,7 +278,7 @@ megasas_enable_intr_ppc(struct megasas_r 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);@@ -396,8 +399,7 @@ megasas_issue_blocked_cmd(struct megasas  	instance->instancet->fire_cmd(cmd->frame_phys_addr ,0,instance->reg_set); -	wait_event_timeout(instance->int_cmd_wait_q, (cmd->cmd_status != ENODATA),-		MEGASAS_INTERNAL_CMD_WAIT_TIME*HZ);+	wait_event(instance->int_cmd_wait_q, (cmd->cmd_status != ENODATA));  	return 0; }@@ -444,8 +446,7 @@ megasas_issue_blocked_abort_cmd(struct m 	/* 	 * Wait for this cmd to complete 	 */-	wait_event_timeout(instance->abort_cmd_wait_q, (cmd->cmd_status != 0xFF),-		MEGASAS_INTERNAL_CMD_WAIT_TIME*HZ);+	wait_event(instance->abort_cmd_wait_q, (cmd->cmd_status != 0xFF));  	megasas_return_cmd(instance, cmd); 	return 0;@@ -460,7 +461,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 +509,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 +550,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 +567,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 +588,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 +598,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) {@@ -667,7 +668,7 @@ megasas_build_dcdb(struct megasas_instan  *  * Frames (and accompanying SGLs) for regular SCSI IOs use this function.  */-static int+static inline int megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp, 		   struct megasas_cmd *cmd) {@@ -803,7 +804,7 @@ static inline int megasas_is_ldio(struct }   /**- * megasas_dump_pending_frames -	Dumps the frame address of all pending cmds+ * megasas_dump_pending_frames -	Dumps the frame address of all pending cmds   *                              	in FW  * @instance:				Adapter soft state  */@@ -820,17 +821,19 @@ megasas_dump_pending_frames(struct megas  	printk(KERN_ERR "\nmegasas[%d]: Dumping Frame Phys Address of all pending cmds in FW\n",instance->host->host_no); 	printk(KERN_ERR "megasas[%d]: Total OS Pending cmds : %d\n",instance->host->host_no,atomic_read(&instance->fw_outstanding));-	if (IS_DMA64)+	if (IS_DMA64)  		printk(KERN_ERR "\nmegasas[%d]: 64 bit SGLs were sent to FW\n",instance->host->host_no); 	else 		printk(KERN_ERR "\nmegasas[%d]: 32 bit SGLs were sent to FW\n",instance->host->host_no);-+		 	printk(KERN_ERR "megasas[%d]: Pending OS cmds in FW : \n",instance->host->host_no); 	for (i = 0; i < max_cmd; i++) { 		cmd = instance->cmd_list[i]; 		if(!cmd->scmd) 			continue;+ 		printk(KERN_ERR "megasas[%d]: Frame addr :0x%08lx : ",instance->host->host_no,(unsigned long)cmd->frame_phys_addr);+		 		if (megasas_is_ldio(cmd->scmd)){ 			ldio = (struct megasas_io_frame *)cmd->frame; 			mfi_sgl = &ldio->sgl;@@ -845,7 +848,7 @@ megasas_dump_pending_frames(struct megas 		} 	if(megasas_dbg_lvl & MEGASAS_DBG_LVL){ 		for (n = 0; n < sgcount; n++){-			if (IS_DMA64)+			if (IS_DMA64)  				printk(KERN_ERR "megasas: sgl len : 0x%x, sgl addr : 0x%08lx ",mfi_sgl->sge64[n].length , (unsigned long)mfi_sgl->sge64[n].phys_addr) ; 			else 				printk(KERN_ERR "megasas: sgl len : 0x%x, sgl addr : 0x%x ",mfi_sgl->sge32[n].length , mfi_sgl->sge32[n].phys_addr) ;@@ -876,17 +879,17 @@ megasas_queue_command(struct scsi_cmnd * 	u32 frame_count; 	struct megasas_cmd *cmd; 	struct megasas_instance *instance;+	unsigned long sec;  	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;@@ -894,13 +897,24 @@ megasas_queue_command(struct scsi_cmnd * 	}  	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;+		case SYNCHRONIZE_CACHE:+			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;+		if(sec<10) +			return SCSI_MLQUEUE_HOST_BUSY;+		else{+			instance->is_busy=0;+			instance->last_time=0;+		}+	}++	if(scmd->retries>1){+		instance->is_busy=1;+		instance->last_time=jiffies; 	}  	cmd = megasas_get_cmd(instance);@@ -920,6 +934,7 @@ 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@@ -937,40 +952,20 @@ 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; 	u32 context;+	unsigned long flags; 	struct megasas_cmd *cmd; 	struct megasas_instance *instance = (struct megasas_instance *)instance_addr;-	unsigned long flags;  	/* If we have already declared adapter dead, donot complete cmds */ 	if (instance->hw_crit_error)@@ -978,9 +973,9 @@ static void megasas_complete_cmd_dpc(uns  	spin_lock_irqsave(&instance->completion_lock, flags); -	producer = *instance->producer;-	consumer = *instance->consumer;-+ 	producer = *instance->producer;+ 	consumer = *instance->consumer;+  	while (consumer != producer) { 		context = instance->reply_queue[consumer]; @@ -1026,7 +1021,7 @@ static int megasas_wait_for_outstanding( 			 * Call cmd completion routine. Cmd to be  			 * be completed directly without depending on isr. 			 */-			megasas_complete_cmd_dpc((unsigned long)instance);+			megasas_complete_cmd_dpc(instance); 		}  		msleep(1000);@@ -1062,8 +1057,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,46 +1067,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"); -	return ret_val;-}-- /**- * megasas_reset_timer - quiesce the adapter if required- * @scmd:		scsi cmnd- *- * Sets the FW busy flag and reduces the host->can_queue if the- * cmd has not been completed within the timeout period.- */-static enum-scsi_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)-{-	struct megasas_cmd *cmd = (struct megasas_cmd *)scmd->SCp.ptr;-	struct megasas_instance *instance;-	unsigned long flags;--	if (time_after(jiffies, scmd->jiffies_at_alloc +-				(MEGASAS_DEFAULT_CMD_TIMEOUT * 2) * HZ)) {-		return EH_NOT_HANDLED;-	}+	spin_lock(scmd->device->host->host_lock); -	instance = cmd->instance;-	if (!(instance->flag & MEGASAS_FW_BUSY)) {-		/* FW is busy, throttle IO */-		spin_lock_irqsave(instance->host->host_lock, flags);--		instance->host->can_queue = 16;-		instance->last_time = jiffies;-		instance->flag |= MEGASAS_FW_BUSY;--		spin_unlock_irqrestore(instance->host->host_lock, flags);-	}-	return EH_RESET_TIMER;+	return ret_val; }  /**@@ -1143,47 +1110,47 @@ static int megasas_reset_bus_host(struct 	return ret; } -/**- * megasas_bios_param - Returns disk geometry for a disk- * @sdev: 		device handle- * @bdev:		block device- * @capacity:		drive capacity- * @geom:		geometry parameters- */-static int-megasas_bios_param(struct scsi_device *sdev, struct block_device *bdev,-		 sector_t capacity, int geom[])-{-	int heads;-	int sectors;-	sector_t cylinders;-	unsigned long tmp;-	/* Default heads (64) & sectors (32) */-	heads = 64;-	sectors = 32;--	tmp = heads * sectors;-	cylinders = capacity;+ /**+ * megasas_bios_param - handle bios geometry+ * sdev: 	device handle+ * bdev:	block device+ * capacity:	drive cpacity+ * geom[]:	geometry parameter+ * 	+ */+static int megasas_bios_param(struct scsi_device *sdev, struct block_device *bdev, sector_t capacity, int geom[])+{+	int 		heads;+	int 		sectors;+	sector_t	cylinders;+	ulong		dummy;+	+	heads 		= 64;+	sectors 	= 32; -	sector_div(cylinders, tmp);+	dummy		= heads * sectors;+	cylinders	=  capacity; +	sector_div(cylinders, dummy);+	 	/*-	 * Handle extended translation size for logical drives > 1Gb-	 */--	if (capacity >= 0x200000) {+	* handle > 1 GB+	*/	+	+	if ((ulong)capacity >= 0x200000) { 		heads = 255; 		sectors = 63;-		tmp = heads*sectors;+		dummy = heads*sectors; 		cylinders = capacity;-		sector_div(cylinders, tmp);+		sector_div(cylinders, dummy); 	}-+	 	geom[0] = heads; 	geom[1] = sectors; 	geom[2] = cylinders;  	return 0;+  }  /**@@ -1213,6 +1180,16 @@ 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)

⌨️ 快捷键说明

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