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

📄 rhel3.patch

📁 最新的Megaraid SAS卡驱动源代码
💻 PATCH
📖 第 1 页 / 共 5 页
字号:
diff -uprN base/Makefile rhel3/Makefile--- base/Makefile	2007-10-13 20:01:18.000000000 -0700+++ rhel3/Makefile	2007-10-13 20:01:18.000000000 -0700@@ -1 +1,9 @@-obj-m	+= megaraid_sas.o+#+# DKMS Makefile for megaraid_sas+#++CFLAGS_megaraid_sas.o = -I$(TOPDIR)/drivers/scsi++obj-m += megaraid_sas.o++include $(TOPDIR)/Rules.makediff -uprN base/megaraid_sas.c rhel3/megaraid_sas.c--- base/megaraid_sas.c	2007-10-13 20:49:29.000000000 -0700+++ rhel3/megaraid_sas.c	2007-10-15 00:36:01.000000000 -0700@@ -28,22 +28,30 @@ #include <linux/types.h> #include <linux/pci.h> #include <linux/list.h>-#include <linux/moduleparam.h>+#include <linux/version.h> #include <linux/module.h>+#include <linux/moduleparam.h> #include <linux/spinlock.h> #include <linux/interrupt.h> #include <linux/delay.h> #include <linux/uio.h> #include <asm/uaccess.h>-#include <linux/fs.h>-#include <linux/compat.h>-#include <linux/blkdev.h>-#include <linux/mutex.h>--#include <scsi/scsi.h>-#include <scsi/scsi_cmnd.h>-#include <scsi/scsi_device.h>-#include <scsi/scsi_host.h>++#include <linux/module.h>++#include <linux/reboot.h>+#include <linux/proc_fs.h>+#include <linux/blk.h>+#include <linux/notifier.h>++#if defined (__x86_64__)+#include <asm/ioctl32.h>+#endif++#include "scsi.h"+#include "hosts.h"+#include "sd.h"+ #include "megaraid_sas.h"  /*@@ -53,50 +61,75 @@ /*  * Fast driver load option, skip scanning for physical devices during load.  * This would result in physical devices being skipped during driver load- * time. These can be later added though, using /proc/scsi/scsi+ * time.  */ static unsigned int fast_load = 0;-module_param_named(fast_load, fast_load, int, 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  * Will be set in megasas_init_mfi if user does not provide  */-static unsigned int max_sectors = 0;-module_param_named(max_sectors, max_sectors, int, 0);-MODULE_PARM_DESC(max_sectors,+static unsigned int max_sector = 0;+module_param(max_sector, int, 0);+MODULE_PARM_DESC(max_sector, 	"Maximum number of sectors per IO command");  /*  * Number of cmds per logical unit  */ static unsigned int cmd_per_lun = MEGASAS_DEFAULT_CMD_PER_LUN;-module_param_named(cmd_per_lun, cmd_per_lun, int, 0);+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);+#endif MODULE_AUTHOR("megaraidlinux@lsi.com"); MODULE_DESCRIPTION("LSI Logic MegaRAID SAS Driver"); +static const char *megasas_info(struct Scsi_Host *);+static void msleep(unsigned long);++static void+megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd,+		     u8 alt_status);+ /*  * PCI ID table for all supported controllers  */ static struct pci_device_id megasas_pci_table[] = { -	{PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1064R)},-	/* xscale IOP */-	{PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_SAS1078R)},-	/* ppc IOP */-	{PCI_DEVICE(PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_LSI_VERDE_ZCR)},-	/* xscale IOP, vega */-	{PCI_DEVICE(PCI_VENDOR_ID_DELL, PCI_DEVICE_ID_DELL_PERC5)},-	/* xscale IOP */-	{}+	{+	 PCI_VENDOR_ID_LSI_LOGIC,+	 PCI_DEVICE_ID_LSI_SAS1064R, // xscale IOP+	 PCI_ANY_ID,+	 PCI_ANY_ID,+	 },+	{+	 PCI_VENDOR_ID_LSI_LOGIC,+	 PCI_DEVICE_ID_LSI_SAS1078R, // ppc IOP+	 PCI_ANY_ID,+	 PCI_ANY_ID,+	},+	{+	 PCI_VENDOR_ID_LSI_LOGIC,+	 PCI_DEVICE_ID_LSI_VERDE_ZCR,	// vega+	 PCI_ANY_ID,+	 PCI_ANY_ID,+	 },+	{+	 PCI_VENDOR_ID_DELL,+	 PCI_DEVICE_ID_DELL_PERC5, // xscale IOP+	 PCI_ANY_ID,+	 PCI_ANY_ID,+	 },+	{0}			/* Terminating entry */+ };  MODULE_DEVICE_TABLE(pci, megasas_pci_table);@@ -104,20 +137,151 @@ 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);+/*for IOCTL mem pool*/+int arr[MAX_IOCTL_MEM_POOL] = {MAX_4K_BUFF,MAX_8K_BUFF,MAX_64K_BUFF};++int arr_size[MAX_IOCTL_MEM_POOL] = {MEGASAS_INIT_IOCTL_MEM_SIZE/*4k*/,+				2*MEGASAS_INIT_IOCTL_MEM_SIZE/*8k*/,+				16*MEGASAS_INIT_IOCTL_MEM_SIZE/*64k*/};++#ifdef CONFIG_PROC_FS+static struct proc_dir_entry *megasas_proc_root;+static struct proc_dir_entry *megasas_proc_hba_map;+static struct proc_dir_entry *megasas_proc_version;+static struct proc_dir_entry *megasas_proc_release_date;+static struct proc_dir_entry *megasas_proc_dbg_lvl;+#endif++static const char *megasas_info(struct Scsi_Host *host)+{+	return "LSI Logic Corporation MegaRAID SAS Driver";+}++static inline unsigned long msecs_to_jiffies(unsigned long msecs)+{+	return ((HZ * msecs + 999) / 1000);+}++static void msleep(unsigned long msecs)+{+	set_current_state(TASK_UNINTERRUPTIBLE);+	schedule_timeout(msecs_to_jiffies(msecs) + 1);+}++static int+megasas_proc_show_version(char *page, char **start, off_t offset, int count,+			  int *eof, void *data)+{+	*eof = 1;+	return (snprintf(page, strlen(MEGASAS_VERSION) + 2, "%s\n",+			 MEGASAS_VERSION));+}++static int+megasas_proc_show_release_date(char *page, char **start, off_t offset,+			       int count, int *eof, void *data)+{+	*eof = 1;+	return (snprintf(page, strlen(MEGASAS_RELDATE) + 2, "%s\n",+			 MEGASAS_RELDATE));+}++static int+megasas_proc_show_dbg_lvl(char *page, char **start, off_t offset,+			       int count, int *eof, void *data)+{+	*eof = 1;+	return sprintf(page,"%u",megasas_dbg_lvl);++}++static int +megasas_proc_get_dbg_lvl(char *page, char **start, off_t off, int count,+         int *eof, void *data)+{+	*eof = 1;+	int retval = count;+	+	if(sscanf(page,"%u",&megasas_dbg_lvl)<1){+		printk(KERN_ERR "megasas: could not set dbg_lvl\n");+		retval = -EINVAL;+	}+	return retval;++}++static int+megasas_proc_show_max_sectors(char *page, char **start, off_t offset,+			       int count, int *eof, void *data)+{+	*eof = 1;+	return sprintf(page,"%u",max_sector);++}++static int+megasas_proc_show_bus_devfn(char *page, char **start, off_t offset,+			    int count, int *eof, void *data)+{+	int i;+	uint32_t bus_devfn = 0;++	struct megasas_instance *instance = (struct megasas_instance *)data;++	for (i = 0; i < megasas_mgmt_info.max_index; i++)+		if (instance == megasas_mgmt_info.instance[i])+			bus_devfn = ((instance->pdev->bus->number) << 16 |+				     (PCI_SLOT(instance->pdev->devfn)) << 8 |+				     (PCI_FUNC(instance->pdev->devfn))) &+			    0xFFFFFF;++	*eof = 1;+	return (sprintf(page, "%d", bus_devfn));+}++static void megasas_create_proc_entry(struct megasas_instance *instance)+{+	unsigned char string[8] = { 0 };++	sprintf(string, "%d", instance->host->host_no);+	instance->hba_proc_dir = proc_mkdir(string, megasas_proc_hba_map);++	if (!instance->hba_proc_dir) {+		printk(KERN_WARNING "megasas: proc creation failed\n");+		return;+	}++	create_proc_read_entry("bus_devfn", S_IRUSR | S_IFREG,+			       instance->hba_proc_dir,+			       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);++}++static void megasas_remove_proc_entry(struct megasas_instance *instance)+{+	unsigned char string[8] = { 0 };++	remove_proc_entry("bus_devfn", instance->hba_proc_dir);+	remove_proc_entry("max_sector", instance->hba_proc_dir);++	sprintf(string, "%d", instance->host->host_no);+	remove_proc_entry(string, megasas_proc_hba_map);+}+ /**  * 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 +345,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 +360,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@@ -385,7 +550,6 @@ megasas_issue_polled(struct megasas_inst  * @cmd:			Command to be issued  *  * This function waits on an event for the command to be returned from ISR.- * Max wait time is MEGASAS_INTERNAL_CMD_WAIT_TIME secs  * Used to issue ioctl commands.  */ static int@@ -396,8 +560,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; }@@ -410,7 +573,6 @@ megasas_issue_blocked_cmd(struct megasas  * MFI firmware can abort previously issued AEN comamnd (automatic event  * notification). The megasas_issue_blocked_abort_cmd() issues such abort  * cmd and waits for return status.- * Max wait time is MEGASAS_INTERNAL_CMD_WAIT_TIME secs  */ static int megasas_issue_blocked_abort_cmd(struct megasas_instance *instance,@@ -444,8 +606,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 +621,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 +669,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) {@@ -555,7 +716,7 @@ megasas_make_sgl64(struct megasas_instan  * 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;@@ -597,7 +758,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) {@@ -624,7 +785,7 @@ megasas_build_dcdb(struct megasas_instan 	pthru->cmd_status = 0x0; 	pthru->scsi_status = 0x0; 	pthru->target_id = device_id;-	pthru->lun = scp->device->lun;+	pthru->lun = scp->lun; 	pthru->cdb_len = scp->cmd_len; 	pthru->timeout = 0; 	pthru->flags = flags;@@ -667,7 +828,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) {@@ -824,7 +985,7 @@ megasas_dump_pending_frames(struct megas 		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];@@ -876,31 +1037,55 @@ 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->host->hostdata; 	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; 	} +	if (fast_load) {+		if (!MEGASAS_IS_LOGICAL(scmd)) {+			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;+		case SYNCHRONIZE_CACHE:+#if defined(CONFIG_DISKDUMP) || defined(CONFIG_DISKDUMP_MODULE)+			if (crashdump_mode())

⌨️ 快捷键说明

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