📄 rhel3-ga.patch
字号:
diff -uprN base/Makefile rhel3-ga/Makefile--- base/Makefile 2007-10-13 20:01:18.000000000 -0700+++ rhel3-ga/Makefile 2007-10-13 20:01:18.000000000 -0700@@ -1 +1,10 @@-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.make+diff -uprN base/megaraid_sas.c rhel3-ga/megaraid_sas.c--- base/megaraid_sas.c 2007-10-13 20:49:29.000000000 -0700+++ rhel3-ga/megaraid_sas.c 2007-10-15 00:36:20.000000000 -0700@@ -28,22 +28,29 @@ #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/init.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,10 +60,10 @@ /* * 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_PARM(fast_load, "i"); MODULE_PARM_DESC(fast_load, "megasas: Faster loading of the driver, skips physical devices! \ (default=0)");@@ -65,38 +72,59 @@ MODULE_PARM_DESC(fast_load, * 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_PARM(max_sector, "i");+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_PARM(cmd_per_lun, "i"); 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 *);+ /* * 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 +132,139 @@ 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 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;@@ -196,6 +343,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@@ -370,7 +518,7 @@ megasas_issue_polled(struct megasas_inst */ for (i = 0; (i < msecs) && (frame_hdr->cmd_status == 0xff); i++) { rmb();- msleep(1);+ mdelay(1); } if (frame_hdr->cmd_status == 0xff)@@ -396,8 +544,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 +591,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 +606,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 +654,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) {@@ -587,7 +733,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 +743,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 +770,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 +813,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) {@@ -776,6 +922,30 @@ megasas_build_ldio(struct megasas_instan return cmd->frame_count; } +static int megasas_abort_command(struct scsi_cmnd *scmd)+{+ int ret = SUCCESS;+ unsigned long flags;+ struct list_head *pos, *next;+ struct megasas_cmd *cmd;+ struct megasas_instance *instance;++ instance = (struct megasas_instance *)scmd->host->hostdata;++ /*+ * Iterate through the pending list and see if fw has the cmd. If fw+ * has the command, return FAILED. Let the call come to reset.+ */+ list_for_each_safe(pos, next, &instance->pending_list) {+ cmd = list_entry(pos, struct megasas_cmd, list);++ if (cmd->scmd == scmd)+ ret = FAILED;+ }++ return ret;+}+ /** * megasas_is_ldio - Checks if the cmd is for logical drive * @scmd: SCSI command@@ -824,7 +994,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,16 +1046,16 @@ megasas_queue_command(struct scsi_cmnd * u32 frame_count; struct megasas_cmd *cmd; struct megasas_instance *instance;+ unsigned long flags;+ 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)) {@@ -893,14 +1063,32 @@ megasas_queue_command(struct scsi_cmnd * 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:+ 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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -