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

📄 ips.c

📁 Linux内核源代码 为压缩文件 是<<Linux内核>>一书中的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
   METHOD_TRACE("ips_release", 1);   for (i = 0; i < IPS_MAX_ADAPTERS && ips_sh[i] != sh; i++);   if (i == IPS_MAX_ADAPTERS)      panic("(%s) release, invalid Scsi_Host pointer.\n",            ips_name);   ha = IPS_HA(sh);   if (!ha)      return (FALSE);   /* flush the cache on the controller */   scb = &ha->scbs[ha->max_cmds-1];   ips_init_scb(ha, scb);   scb->timeout = ips_cmd_timeout;   scb->cdb[0] = IPS_CMD_FLUSH;   scb->cmd.flush_cache.op_code = IPS_CMD_FLUSH;   scb->cmd.flush_cache.command_id = IPS_COMMAND_ID(ha, scb);   scb->cmd.flush_cache.state = IPS_NORM_STATE;   scb->cmd.flush_cache.reserved = 0;   scb->cmd.flush_cache.reserved2 = 0;   scb->cmd.flush_cache.reserved3 = 0;   scb->cmd.flush_cache.reserved4 = 0;   printk("(%s%d) Flushing Cache.\n", ips_name, ha->host_num);   /* send command */   if (ips_send_wait(ha, scb, ips_cmd_timeout, IPS_INTR_ON) == IPS_FAILURE)      printk("(%s%d) Incomplete Flush.\n", ips_name, ha->host_num);   printk("(%s%d) Flushing Complete.\n", ips_name, ha->host_num);   ips_sh[i] = NULL;   ips_ha[i] = NULL;   /* free extra memory */   ips_free(ha);   /* Free I/O Region */   if (ha->io_addr)      release_region(ha->io_addr, ha->io_len);#if LINUX_VERSION_CODE >= LinuxVersionCode(2,3,17)   if (ha->mem_addr)      release_mem_region(ha->mem_addr, ha->mem_len);#endif   /* free IRQ */   free_irq(ha->irq, ha);   ips_released_controllers++;   if (ips_num_controllers == ips_released_controllers)      unregister_reboot_notifier(&ips_notifier);   return (FALSE);}/****************************************************************************//*                                                                          *//* Routine Name: ips_halt                                                   *//*                                                                          *//* Routine Description:                                                     *//*                                                                          *//*   Perform cleanup when the system reboots                                *//*                                                                          *//****************************************************************************/static intips_halt(struct notifier_block *nb, ulong event, void *buf) {   ips_scb_t *scb;   ips_ha_t  *ha;   int        i;   if ((event != SYS_RESTART) && (event != SYS_HALT) &&       (event != SYS_POWER_OFF))      return (NOTIFY_DONE);   for (i = 0; i < ips_next_controller; i++) {      ha = (ips_ha_t *) ips_ha[i];      if (!ha)         continue;      if (!ha->active)         continue;      /* flush the cache on the controller */      scb = &ha->scbs[ha->max_cmds-1];      ips_init_scb(ha, scb);      scb->timeout = ips_cmd_timeout;      scb->cdb[0] = IPS_CMD_FLUSH;      scb->cmd.flush_cache.op_code = IPS_CMD_FLUSH;      scb->cmd.flush_cache.command_id = IPS_COMMAND_ID(ha, scb);      scb->cmd.flush_cache.state = IPS_NORM_STATE;      scb->cmd.flush_cache.reserved = 0;      scb->cmd.flush_cache.reserved2 = 0;      scb->cmd.flush_cache.reserved3 = 0;      scb->cmd.flush_cache.reserved4 = 0;      printk("(%s%d) Flushing Cache.\n", ips_name, ha->host_num);      /* send command */      if (ips_send_wait(ha, scb, ips_cmd_timeout, IPS_INTR_ON) == IPS_FAILURE)         printk("(%s%d) Incomplete Flush.\n", ips_name, ha->host_num);      else         printk("(%s%d) Flushing Complete.\n", ips_name, ha->host_num);   }   unregister_reboot_notifier(&ips_notifier);   return (NOTIFY_OK);}/****************************************************************************//*                                                                          *//* Routine Name: ips_eh_abort                                               *//*                                                                          *//* Routine Description:                                                     *//*                                                                          *//*   Abort a command (using the new error code stuff)                       *//*                                                                          *//****************************************************************************/intips_eh_abort(Scsi_Cmnd *SC) {   ips_ha_t         *ha;   ips_copp_wait_item_t *item;   METHOD_TRACE("ips_eh_abort", 1);   if (!SC)      return (FAILED);   ha = (ips_ha_t *) SC->host->hostdata;   if (!ha)      return (FAILED);   if (!ha->active)      return (FAILED);   if (SC->serial_number != SC->serial_number_at_timeout) {      /* HMM, looks like a bogus command */      DEBUG(1, "Abort called with bogus scsi command");      return (FAILED);   }   if (test_and_set_bit(IPS_IN_ABORT, &ha->flags))      return (FAILED);   /* See if the command is on the copp queue */   IPS_QUEUE_LOCK(&ha->copp_waitlist);   item = ha->copp_waitlist.head;   while ((item) && (item->scsi_cmd != SC))      item = item->next;   IPS_QUEUE_UNLOCK(&ha->copp_waitlist);   if (item) {      /* Found it */      ips_removeq_copp(&ha->copp_waitlist, item);      clear_bit(IPS_IN_ABORT, &ha->flags);      return (SUCCESS);   }   /* See if the command is on the wait queue */   if (ips_removeq_wait(&ha->scb_waitlist, SC)) {      /* command not sent yet */      clear_bit(IPS_IN_ABORT, &ha->flags);      return (SUCCESS);   } else {      /* command must have already been sent */      clear_bit(IPS_IN_ABORT, &ha->flags);      return (FAILED);   }}/****************************************************************************//*                                                                          *//* Routine Name: ips_eh_reset                                               *//*                                                                          *//* Routine Description:                                                     *//*                                                                          *//*   Reset the controller (with new eh error code)                          *//*                                                                          *//* NOTE: this routine is called under the io_request_lock spinlock          *//*                                                                          *//****************************************************************************/intips_eh_reset(Scsi_Cmnd *SC) {   int                   ret;   int                   i;   u32                   cpu_flags;   ips_ha_t             *ha;   ips_scb_t            *scb;   ips_copp_wait_item_t *item;   METHOD_TRACE("ips_eh_reset", 1);#ifdef NO_IPS_RESET   return (FAILED);#else   if (!SC) {      DEBUG(1, "Reset called with NULL scsi command");      return (FAILED);   }   ha = (ips_ha_t *) SC->host->hostdata;   if (!ha) {      DEBUG(1, "Reset called with NULL ha struct");      return (FAILED);   }   if (!ha->active)      return (FAILED);   if (test_and_set_bit(IPS_IN_RESET, &ha->flags))      return (FAILED);   /* See if the command is on the copp queue */   IPS_QUEUE_LOCK(&ha->copp_waitlist);   item = ha->copp_waitlist.head;   while ((item) && (item->scsi_cmd != SC))      item = item->next;   IPS_QUEUE_UNLOCK(&ha->copp_waitlist);   if (item) {      /* Found it */      ips_removeq_copp(&ha->copp_waitlist, item);      clear_bit(IPS_IN_RESET, &ha->flags);      return (SUCCESS);   }   /* See if the command is on the wait queue */   if (ips_removeq_wait(&ha->scb_waitlist, SC)) {      /* command not sent yet */      clear_bit(IPS_IN_RESET, &ha->flags);      return (SUCCESS);   }   /*    * command must have already been sent    * reset the controller    */   printk(KERN_NOTICE "(%s%d) Resetting controller.\n",          ips_name, ha->host_num);   ret = (*ha->func.reset)(ha);   if (!ret) {      Scsi_Cmnd *scsi_cmd;      printk(KERN_NOTICE              "(%s%d) Controller reset failed - controller now offline.\n",             ips_name, ha->host_num);      /* Now fail all of the active commands */      DEBUG_VAR(1, "(%s%d) Failing active commands",                ips_name, ha->host_num);      while ((scb = ips_removeq_scb_head(&ha->scb_activelist))) {         scb->scsi_cmd->result = DID_ERROR << 16;         scb->scsi_cmd->scsi_done(scb->scsi_cmd);         ips_freescb(ha, scb);      }      /* Now fail all of the pending commands */      DEBUG_VAR(1, "(%s%d) Failing pending commands",                ips_name, ha->host_num);      while ((scsi_cmd = ips_removeq_wait_head(&ha->scb_waitlist))) {         scsi_cmd->result = DID_ERROR;         scsi_cmd->scsi_done(scsi_cmd);      }      ha->active = FALSE;      clear_bit(IPS_IN_RESET, &ha->flags);      return (FAILED);   }   if (!ips_clear_adapter(ha, IPS_INTR_IORL)) {      Scsi_Cmnd *scsi_cmd;      printk(KERN_NOTICE              "(%s%d) Controller reset failed - controller now offline.\n",             ips_name, ha->host_num);      /* Now fail all of the active commands */      DEBUG_VAR(1, "(%s%d) Failing active commands",                ips_name, ha->host_num);      while ((scb = ips_removeq_scb_head(&ha->scb_activelist))) {         scb->scsi_cmd->result = DID_ERROR << 16;         scb->scsi_cmd->scsi_done(scb->scsi_cmd);         ips_freescb(ha, scb);      }      /* Now fail all of the pending commands */      DEBUG_VAR(1, "(%s%d) Failing pending commands",                ips_name, ha->host_num);      while ((scsi_cmd = ips_removeq_wait_head(&ha->scb_waitlist))) {         scsi_cmd->result = DID_ERROR << 16;         scsi_cmd->scsi_done(scsi_cmd);      }      ha->active = FALSE;      clear_bit(IPS_IN_RESET, &ha->flags);      return (FAILED);   }   /* FFDC */   if (ha->subsys->param[3] & 0x300000) {      struct timeval tv;      do_gettimeofday(&tv);      IPS_HA_LOCK(cpu_flags);      ha->last_ffdc = tv.tv_sec;      ha->reset_count++;      IPS_HA_UNLOCK(cpu_flags);      ips_ffdc_reset(ha, IPS_INTR_IORL);   }   /* Now fail all of the active commands */   DEBUG_VAR(1, "(%s%d) Failing active commands",             ips_name, ha->host_num);   while ((scb = ips_removeq_scb_head(&ha->scb_activelist))) {      scb->scsi_cmd->result = (DID_RESET << 16) | (SUGGEST_RETRY << 24);      scb->scsi_cmd->scsi_done(scb->scsi_cmd);      ips_freescb(ha, scb);   }   /* Reset DCDB active command bits */   for (i = 1; i < ha->nbus; i++)      ha->dcdb_active[i-1] = 0;   /* Reset the number of active IOCTLs */   IPS_HA_LOCK(cpu_flags);   ha->num_ioctl = 0;   IPS_HA_UNLOCK(cpu_flags);   clear_bit(IPS_IN_RESET, &ha->flags);   if (!test_bit(IPS_IN_INTR, &ha->flags)) {      /*       * Only execute the next command when       * we are not being called from the       * interrupt handler.  The interrupt       * handler wants to do this and since       * interrupts are turned off here....       */      ips_next(ha, IPS_INTR_IORL);

⌨️ 快捷键说明

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