📄 rhel4.patch
字号:
+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 megasas_instance *megasas_lookup_instance(u16 host_no) { int i;@@ -1262,8 +1344,10 @@ static struct scsi_host_template megasas .eh_bus_reset_handler = megasas_reset_bus_host, .eh_host_reset_handler = megasas_reset_bus_host, .eh_timed_out = megasas_reset_timer,- .bios_param = megasas_bios_param,+ .bios_param = megasas_bios_param, .use_clustering = ENABLE_CLUSTERING,+ .dump_sanity_check = megasas_diskdump_sanity_check,+ .dump_poll = megasas_diskdump_poll, }; /**@@ -1314,7 +1398,7 @@ megasas_complete_abort(struct megasas_in * @instance: Adapter soft state * @cmd: Completed command */-static void+static inline void megasas_unmap_sgbuf(struct megasas_instance *instance, struct megasas_cmd *cmd) { dma_addr_t buf_h;@@ -1364,7 +1448,6 @@ megasas_complete_cmd(struct megasas_inst { int exception = 0; struct megasas_header *hdr = &cmd->frame->hdr;- unsigned long flags; if (cmd->scmd) cmd->scmd->SCp.ptr = NULL;@@ -1385,6 +1468,20 @@ megasas_complete_cmd(struct megasas_inst break; } + /*+ * Don't export physical disk devices to mid-layer.+ */+ if (!MEGASAS_IS_LOGICAL(cmd->scmd) &&+ (hdr->cmd_status == MFI_STAT_OK) &&+ (cmd->scmd->cmnd[0] == INQUIRY)) {++ if (((*(u8 *) cmd->scmd->request_buffer) & 0x1F) ==+ TYPE_DISK) {+ cmd->scmd->result = DID_BAD_TARGET << 16;+ exception = 1;+ }+ }+ case MFI_CMD_LD_READ: case MFI_CMD_LD_WRITE: @@ -1477,22 +1574,6 @@ megasas_complete_cmd(struct megasas_inst hdr->cmd); break; }- - /*- * 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);- }- } /**@@ -1502,9 +1583,10 @@ megasas_complete_cmd(struct megasas_inst * SCSI mid-layer instead of the status * returned by the FW */-static int+static inline int megasas_deplete_reply_queue(struct megasas_instance *instance, u8 alt_status) {+ /* * Check if it is our interrupt * Clear the interrupt @@ -1512,12 +1594,13 @@ megasas_deplete_reply_queue(struct megas if(instance->instancet->clear_intr(instance->reg_set)) return IRQ_NONE; - if (instance->hw_crit_error)+ if(instance->hw_crit_error) goto out_done;- /*- * Schedule the tasklet for cmd completion- */+ /* + * Schedule the tasklet for cmd completion + */ tasklet_schedule(&instance->isr_tasklet);+ out_done: return IRQ_HANDLED; }@@ -1525,7 +1608,7 @@ out_done: /** * megasas_isr - isr entry point */-static irqreturn_t megasas_isr(int irq, void *devp)+static irqreturn_t megasas_isr(int irq, void *devp, struct pt_regs *regs) { return megasas_deplete_reply_queue((struct megasas_instance *)devp, DID_OK);@@ -1550,7 +1633,7 @@ megasas_transition_to_ready(struct megas fw_state = instance->instancet->read_fw_status_reg(instance->reg_set) & MFI_STATE_MASK; - if (fw_state != MFI_STATE_READY)+ if (fw_state != MFI_STATE_READY) printk(KERN_INFO "megasas: Waiting for FW to come to ready" " state\n"); @@ -1574,7 +1657,7 @@ megasas_transition_to_ready(struct megas cur_state = MFI_STATE_WAIT_HANDSHAKE; break; - case MFI_STATE_BOOT_MESSAGE_PENDING:+ case MFI_STATE_BOOT_MESSAGE_PENDING: writel(MFI_INIT_HOTPLUG, &instance->reg_set->inbound_doorbell); @@ -1640,7 +1723,7 @@ megasas_transition_to_ready(struct megas MFI_STATE_MASK ; if (fw_state == cur_state) {- msleep(1);+ megasas_msleep(1); } else break; }@@ -1960,81 +2043,6 @@ megasas_get_ctrl_info(struct megasas_ins } /**- * megasas_issue_init_mfi - Initializes the FW- * @instance: Adapter soft state- *- * Issues the INIT MFI cmd- */-static int-megasas_issue_init_mfi(struct megasas_instance *instance)-{- u32 context;-- struct megasas_cmd *cmd;-- struct megasas_init_frame *init_frame;- struct megasas_init_queue_info *initq_info;- dma_addr_t init_frame_h;- dma_addr_t initq_info_h;-- /*- * Prepare a init frame. Note the init frame points to queue info- * structure. Each frame has SGL allocated after first 64 bytes. For- * this frame - since we don't need any SGL - we use SGL's space as- * queue info structure- *- * We will not get a NULL command below. We just created the pool.- */- cmd = megasas_get_cmd(instance);-- init_frame = (struct megasas_init_frame *)cmd->frame;- initq_info = (struct megasas_init_queue_info *)- ((unsigned long)init_frame + 64);-- init_frame_h = cmd->frame_phys_addr;- initq_info_h = init_frame_h + 64;-- context = init_frame->context;- memset(init_frame, 0, MEGAMFI_FRAME_SIZE);- memset(initq_info, 0, sizeof(struct megasas_init_queue_info));- init_frame->context = context;- - initq_info->reply_queue_entries = instance->max_fw_cmds + 1;- initq_info->reply_queue_start_phys_addr_lo = instance->reply_queue_h;-- initq_info->producer_index_phys_addr_lo = instance->producer_h;- initq_info->consumer_index_phys_addr_lo = instance->consumer_h;-- init_frame->cmd = MFI_CMD_INIT;- init_frame->cmd_status = 0xFF;- init_frame->queue_info_new_phys_addr_lo = initq_info_h;-- init_frame->data_xfer_len = sizeof(struct megasas_init_queue_info);-- /*- * disable the intr before firing the init frame to FW - */ - instance->instancet->disable_intr(instance->reg_set);- - /*- * Issue the init frame in polled mode- */-- if (megasas_issue_polled(instance, cmd)) {- printk(KERN_DEBUG "megasas: Failed to init firmware\n");- megasas_return_cmd(instance, cmd);- goto fail_fw_init;- }-- megasas_return_cmd(instance, cmd);-- return 0;-- fail_fw_init:- return -EINVAL;-}--/** * megasas_init_mfi - Initializes the FW * @instance: Adapter soft state *@@ -2049,8 +2057,14 @@ static int megasas_init_mfi(struct megas u32 tmp_sectors; struct megasas_register_set __iomem *reg_set; + struct megasas_cmd *cmd; struct megasas_ctrl_info *ctrl_info; + struct megasas_init_frame *init_frame;+ struct megasas_init_queue_info *initq_info;+ dma_addr_t init_frame_h;+ dma_addr_t initq_info_h;+ /* * Map the message registers */@@ -2093,9 +2107,9 @@ static int megasas_init_mfi(struct megas */ instance->max_fw_cmds = instance->instancet->read_fw_status_reg(reg_set) & 0x00FFFF; /*- * Reduce the max supported cmds by 1. This is to ensure that the+ * Reduce the max supported FW cmds by 1. This is to ensure that the * reply_q_sz (1 more than the max cmd that driver may send)- * does not exceed max cmds that the FW can support+ * does not exceed max_fw_cmds */ instance->max_fw_cmds = instance->max_fw_cmds-1; instance->max_num_sge = (instance->instancet->read_fw_status_reg(reg_set) & 0xFF0000) >> @@ -2126,9 +2140,53 @@ static int megasas_init_mfi(struct megas printk(KERN_DEBUG "megasas: Out of DMA mem for reply queue\n"); goto fail_reply_queue; }++ /*+ * Prepare a init frame. Note the init frame points to queue info+ * structure. Each frame has SGL allocated after first 64 bytes. For+ * this frame - since we don't need any SGL - we use SGL's space as+ * queue info structure+ *+ * We will not get a NULL command below. We just created the pool.+ */+ cmd = megasas_get_cmd(instance);++ init_frame = (struct megasas_init_frame *)cmd->frame;+ initq_info = (struct megasas_init_queue_info *)+ ((unsigned long)init_frame + 64);++ init_frame_h = cmd->frame_phys_addr;+ initq_info_h = init_frame_h + 64;++ memset(init_frame, 0, MEGAMFI_FRAME_SIZE);+ memset(initq_info, 0, sizeof(struct megasas_init_queue_info));++ initq_info->reply_queue_entries = instance->max_fw_cmds + 1;+ initq_info->reply_queue_start_phys_addr_lo = instance->reply_queue_h;++ initq_info->producer_index_phys_addr_lo = instance->producer_h;+ initq_info->consumer_index_phys_addr_lo = instance->consumer_h;++ init_frame->cmd = MFI_CMD_INIT;+ init_frame->cmd_status = 0xFF;+ init_frame->queue_info_new_phys_addr_lo = initq_info_h;++ init_frame->data_xfer_len = sizeof(struct megasas_init_queue_info);++ /*+ * disable the intr before firing the init frame to FW + */ + instance->instancet->disable_intr(instance->reg_set); - if (megasas_issue_init_mfi(instance))+ /*+ * Issue the init frame in polled mode+ */+ if (megasas_issue_polled(instance, cmd)) {+ printk(KERN_DEBUG "megasas: Failed to init firmware\n"); goto fail_fw_init;+ }++ megasas_return_cmd(instance, cmd); ctrl_info = kmalloc(sizeof(struct megasas_ctrl_info), GFP_KERNEL); @@ -2153,7 +2211,7 @@ static int megasas_init_mfi(struct megas } 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; @@ -2163,11 +2221,13 @@ static int megasas_init_mfi(struct megas * Setup tasklet for cmd completion */ - tasklet_init(&instance->isr_tasklet, megasas_complete_cmd_dpc,+ tasklet_init(&instance->isr_tasklet, megasas_complete_cmd_dpc, (unsigned long)instance);+ return 0; fail_fw_init:+ megasas_return_cmd(instance, cmd); pci_free_consistent(instance->pdev, reply_q_sz, instance->reply_queue, instance->reply_queue_h);@@ -2412,8 +2472,7 @@ static int megasas_start_aen(struct mega } static ssize_t-sysfs_max_sectors_read(struct kobject *kobj, char *buf,- loff_t off, size_t count)+sysfs_max_sectors_read(struct kobject *kobj, char *buf, loff_t off, size_t count) { struct Scsi_Host *host = class_to_shost(container_of(kobj, struct class_device, kobj));@@ -2494,21 +2553,22 @@ static int megasas_io_attach(struct mega return -ENODEV; } - /*+ /* * Create sysfs entries for module paramaters */ error = sysfs_create_bin_file(&instance->host->shost_classdev.kobj, &sysfs_max_sectors_attr); if (error) {- printk(KERN_INFO "megasas: Error in creating the sysfs entry"- " max_sectors.\n");+ printk(KERN_INFO "megasas: Error in creating the sysfs entry max_sectors.\n"); goto out_remove_host; } /* * Trigger SCSI to scan our drives */+ scsi_scan_host(host);+ return 0; out_remove_host:@@ -2516,28 +2576,6 @@ out_remove_host: return error; } -static int-megasas_set_dma_mask(struct pci_dev *pdev)-{- /*- * All our contollers are capable of performing 64-bit DMA- */- if (IS_DMA64) {- if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) != 0) {-- if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0)- goto fail_set_dma_mask;- }- } else {- if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0)- goto fail_set_dma_mask;- }- return 0;--fail_set_dma_mask:- return 1;-}- /** * megasas_probe_one - PCI hotplug entry point * @pdev: PCI device structure@@ -2571,8 +2609,19 @@ megasas_probe_one(struct pci_dev *pdev, pci_set_master(pdev); - if (megasas_set_dma_mask(pdev))- goto fail_set_dma_mask;+ /*+ * All our contollers are capable of performing 64-bit DMA+ */+ if (IS_DMA64) {+ if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) != 0) {++ if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0)+ goto fail_set_dma_mask;+ }+ } else {+ if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0)+ goto fail_set_dma_mask;+ } host = scsi_host_alloc(&megasas_template, sizeof(struct megasas_instance));@@ -2647,7 +2696,7 @@ megasas_probe_one(struct pci_dev *pdev, /* * Register IRQ */- if (request_irq(pdev->irq, megasas_isr, IRQF_SHARED, "megasas", instance)) {+ if (request_irq(pdev->irq, megasas_isr, SA_SHIRQ, "megasas", instance)) { printk(KERN_DEBUG "megasas: Failed to register IRQ\n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -