Lines Matching refs:cs
104 static void myrs_qcmd(struct myrs_hba *cs, struct myrs_cmdblk *cmd_blk) in myrs_qcmd() argument
106 void __iomem *base = cs->io_base; in myrs_qcmd()
108 union myrs_cmd_mbox *next_mbox = cs->next_cmd_mbox; in myrs_qcmd()
110 cs->write_cmd_mbox(next_mbox, mbox); in myrs_qcmd()
112 if (cs->prev_cmd_mbox1->words[0] == 0 || in myrs_qcmd()
113 cs->prev_cmd_mbox2->words[0] == 0) in myrs_qcmd()
114 cs->get_cmd_mbox(base); in myrs_qcmd()
116 cs->prev_cmd_mbox2 = cs->prev_cmd_mbox1; in myrs_qcmd()
117 cs->prev_cmd_mbox1 = next_mbox; in myrs_qcmd()
119 if (++next_mbox > cs->last_cmd_mbox) in myrs_qcmd()
120 next_mbox = cs->first_cmd_mbox; in myrs_qcmd()
122 cs->next_cmd_mbox = next_mbox; in myrs_qcmd()
128 static void myrs_exec_cmd(struct myrs_hba *cs, in myrs_exec_cmd() argument
135 spin_lock_irqsave(&cs->queue_lock, flags); in myrs_exec_cmd()
136 myrs_qcmd(cs, cmd_blk); in myrs_exec_cmd()
137 spin_unlock_irqrestore(&cs->queue_lock, flags); in myrs_exec_cmd()
145 static void myrs_report_progress(struct myrs_hba *cs, unsigned short ldev_num, in myrs_report_progress() argument
149 shost_printk(KERN_INFO, cs->host, in myrs_report_progress()
158 static unsigned char myrs_get_ctlr_info(struct myrs_hba *cs) in myrs_get_ctlr_info() argument
160 struct myrs_cmdblk *cmd_blk = &cs->dcmd_blk; in myrs_get_ctlr_info()
167 ldev_present = cs->ctlr_info->ldev_present; in myrs_get_ctlr_info()
168 ldev_critical = cs->ctlr_info->ldev_critical; in myrs_get_ctlr_info()
169 ldev_offline = cs->ctlr_info->ldev_offline; in myrs_get_ctlr_info()
171 ctlr_info_addr = dma_map_single(&cs->pdev->dev, cs->ctlr_info, in myrs_get_ctlr_info()
174 if (dma_mapping_error(&cs->pdev->dev, ctlr_info_addr)) in myrs_get_ctlr_info()
177 mutex_lock(&cs->dcmd_mutex); in myrs_get_ctlr_info()
189 dev_dbg(&cs->host->shost_gendev, "Sending GetControllerInfo\n"); in myrs_get_ctlr_info()
190 myrs_exec_cmd(cs, cmd_blk); in myrs_get_ctlr_info()
192 mutex_unlock(&cs->dcmd_mutex); in myrs_get_ctlr_info()
193 dma_unmap_single(&cs->pdev->dev, ctlr_info_addr, in myrs_get_ctlr_info()
196 if (cs->ctlr_info->bg_init_active + in myrs_get_ctlr_info()
197 cs->ctlr_info->ldev_init_active + in myrs_get_ctlr_info()
198 cs->ctlr_info->pdev_init_active + in myrs_get_ctlr_info()
199 cs->ctlr_info->cc_active + in myrs_get_ctlr_info()
200 cs->ctlr_info->rbld_active + in myrs_get_ctlr_info()
201 cs->ctlr_info->exp_active != 0) in myrs_get_ctlr_info()
202 cs->needs_update = true; in myrs_get_ctlr_info()
203 if (cs->ctlr_info->ldev_present != ldev_present || in myrs_get_ctlr_info()
204 cs->ctlr_info->ldev_critical != ldev_critical || in myrs_get_ctlr_info()
205 cs->ctlr_info->ldev_offline != ldev_offline) in myrs_get_ctlr_info()
206 shost_printk(KERN_INFO, cs->host, in myrs_get_ctlr_info()
208 cs->ctlr_info->ldev_critical, in myrs_get_ctlr_info()
209 cs->ctlr_info->ldev_offline, in myrs_get_ctlr_info()
210 cs->ctlr_info->ldev_present); in myrs_get_ctlr_info()
219 static unsigned char myrs_get_ldev_info(struct myrs_hba *cs, in myrs_get_ldev_info() argument
222 struct myrs_cmdblk *cmd_blk = &cs->dcmd_blk; in myrs_get_ldev_info()
230 ldev_info_addr = dma_map_single(&cs->pdev->dev, ldev_info, in myrs_get_ldev_info()
233 if (dma_mapping_error(&cs->pdev->dev, ldev_info_addr)) in myrs_get_ldev_info()
236 mutex_lock(&cs->dcmd_mutex); in myrs_get_ldev_info()
248 dev_dbg(&cs->host->shost_gendev, in myrs_get_ldev_info()
250 myrs_exec_cmd(cs, cmd_blk); in myrs_get_ldev_info()
252 mutex_unlock(&cs->dcmd_mutex); in myrs_get_ldev_info()
253 dma_unmap_single(&cs->pdev->dev, ldev_info_addr, in myrs_get_ldev_info()
265 shost_printk(KERN_INFO, cs->host, in myrs_get_ldev_info()
272 shost_printk(KERN_INFO, cs->host, in myrs_get_ldev_info()
278 myrs_report_progress(cs, ldev_num, in myrs_get_ldev_info()
282 myrs_report_progress(cs, ldev_num, in myrs_get_ldev_info()
286 myrs_report_progress(cs, ldev_num, in myrs_get_ldev_info()
290 myrs_report_progress(cs, ldev_num, in myrs_get_ldev_info()
294 shost_printk(KERN_INFO, cs->host, in myrs_get_ldev_info()
306 static unsigned char myrs_get_pdev_info(struct myrs_hba *cs, in myrs_get_pdev_info() argument
310 struct myrs_cmdblk *cmd_blk = &cs->dcmd_blk; in myrs_get_pdev_info()
316 pdev_info_addr = dma_map_single(&cs->pdev->dev, pdev_info, in myrs_get_pdev_info()
319 if (dma_mapping_error(&cs->pdev->dev, pdev_info_addr)) in myrs_get_pdev_info()
322 mutex_lock(&cs->dcmd_mutex); in myrs_get_pdev_info()
336 dev_dbg(&cs->host->shost_gendev, in myrs_get_pdev_info()
339 myrs_exec_cmd(cs, cmd_blk); in myrs_get_pdev_info()
341 mutex_unlock(&cs->dcmd_mutex); in myrs_get_pdev_info()
342 dma_unmap_single(&cs->pdev->dev, pdev_info_addr, in myrs_get_pdev_info()
350 static unsigned char myrs_dev_op(struct myrs_hba *cs, in myrs_dev_op() argument
353 struct myrs_cmdblk *cmd_blk = &cs->dcmd_blk; in myrs_dev_op()
357 mutex_lock(&cs->dcmd_mutex); in myrs_dev_op()
365 myrs_exec_cmd(cs, cmd_blk); in myrs_dev_op()
367 mutex_unlock(&cs->dcmd_mutex); in myrs_dev_op()
375 static unsigned char myrs_translate_pdev(struct myrs_hba *cs, in myrs_translate_pdev() argument
379 struct pci_dev *pdev = cs->pdev; in myrs_translate_pdev()
393 mutex_lock(&cs->dcmd_mutex); in myrs_translate_pdev()
394 cmd_blk = &cs->dcmd_blk; in myrs_translate_pdev()
408 myrs_exec_cmd(cs, cmd_blk); in myrs_translate_pdev()
410 mutex_unlock(&cs->dcmd_mutex); in myrs_translate_pdev()
419 static unsigned char myrs_get_event(struct myrs_hba *cs, in myrs_get_event() argument
422 struct pci_dev *pdev = cs->pdev; in myrs_get_event()
424 struct myrs_cmdblk *cmd_blk = &cs->mcmd_blk; in myrs_get_event()
443 myrs_exec_cmd(cs, cmd_blk); in myrs_get_event()
454 static unsigned char myrs_get_fwstatus(struct myrs_hba *cs) in myrs_get_fwstatus() argument
456 struct myrs_cmdblk *cmd_blk = &cs->mcmd_blk; in myrs_get_fwstatus()
469 sgl->sge[0].sge_addr = cs->fwstat_addr; in myrs_get_fwstatus()
471 dev_dbg(&cs->host->shost_gendev, "Sending GetHealthStatus\n"); in myrs_get_fwstatus()
472 myrs_exec_cmd(cs, cmd_blk); in myrs_get_fwstatus()
481 static bool myrs_enable_mmio_mbox(struct myrs_hba *cs, in myrs_enable_mmio_mbox() argument
484 void __iomem *base = cs->io_base; in myrs_enable_mmio_mbox()
485 struct pci_dev *pdev = cs->pdev; in myrs_enable_mmio_mbox()
505 cs->cmd_mbox_size = MYRS_MAX_CMD_MBOX * sizeof(union myrs_cmd_mbox); in myrs_enable_mmio_mbox()
506 cmd_mbox = dma_alloc_coherent(&pdev->dev, cs->cmd_mbox_size, in myrs_enable_mmio_mbox()
507 &cs->cmd_mbox_addr, GFP_KERNEL); in myrs_enable_mmio_mbox()
508 if (dma_mapping_error(&pdev->dev, cs->cmd_mbox_addr)) { in myrs_enable_mmio_mbox()
512 cs->first_cmd_mbox = cmd_mbox; in myrs_enable_mmio_mbox()
514 cs->last_cmd_mbox = cmd_mbox; in myrs_enable_mmio_mbox()
515 cs->next_cmd_mbox = cs->first_cmd_mbox; in myrs_enable_mmio_mbox()
516 cs->prev_cmd_mbox1 = cs->last_cmd_mbox; in myrs_enable_mmio_mbox()
517 cs->prev_cmd_mbox2 = cs->last_cmd_mbox - 1; in myrs_enable_mmio_mbox()
520 cs->stat_mbox_size = MYRS_MAX_STAT_MBOX * sizeof(struct myrs_stat_mbox); in myrs_enable_mmio_mbox()
521 stat_mbox = dma_alloc_coherent(&pdev->dev, cs->stat_mbox_size, in myrs_enable_mmio_mbox()
522 &cs->stat_mbox_addr, GFP_KERNEL); in myrs_enable_mmio_mbox()
523 if (dma_mapping_error(&pdev->dev, cs->stat_mbox_addr)) { in myrs_enable_mmio_mbox()
528 cs->first_stat_mbox = stat_mbox; in myrs_enable_mmio_mbox()
530 cs->last_stat_mbox = stat_mbox; in myrs_enable_mmio_mbox()
531 cs->next_stat_mbox = cs->first_stat_mbox; in myrs_enable_mmio_mbox()
533 cs->fwstat_buf = dma_alloc_coherent(&pdev->dev, in myrs_enable_mmio_mbox()
535 &cs->fwstat_addr, GFP_KERNEL); in myrs_enable_mmio_mbox()
536 if (dma_mapping_error(&pdev->dev, cs->fwstat_addr)) { in myrs_enable_mmio_mbox()
538 cs->fwstat_buf = NULL; in myrs_enable_mmio_mbox()
541 cs->ctlr_info = kzalloc(sizeof(struct myrs_ctlr_info), in myrs_enable_mmio_mbox()
543 if (!cs->ctlr_info) in myrs_enable_mmio_mbox()
546 cs->event_buf = kzalloc(sizeof(struct myrs_event), in myrs_enable_mmio_mbox()
548 if (!cs->event_buf) in myrs_enable_mmio_mbox()
565 mbox->set_mbox.fwstat_buf_addr = cs->fwstat_addr; in myrs_enable_mmio_mbox()
566 mbox->set_mbox.first_cmd_mbox_addr = cs->cmd_mbox_addr; in myrs_enable_mmio_mbox()
567 mbox->set_mbox.first_stat_mbox_addr = cs->stat_mbox_addr; in myrs_enable_mmio_mbox()
582 static int myrs_get_config(struct myrs_hba *cs) in myrs_get_config() argument
584 struct myrs_ctlr_info *info = cs->ctlr_info; in myrs_get_config()
585 struct Scsi_Host *shost = cs->host; in myrs_get_config()
592 mutex_lock(&cs->cinfo_mutex); in myrs_get_config()
593 status = myrs_get_ctlr_info(cs); in myrs_get_config()
594 mutex_unlock(&cs->cinfo_mutex); in myrs_get_config()
610 strcpy(cs->model_name, "DAC960 "); in myrs_get_config()
611 strcat(cs->model_name, model); in myrs_get_config()
813 static void myrs_log_event(struct myrs_hba *cs, struct myrs_event *ev) in myrs_log_event() argument
818 struct Scsi_Host *shost = cs->host; in myrs_log_event()
858 sdev->channel < cs->ctlr_info->physchan_present) { in myrs_log_event()
885 cs->needs_update = true; in myrs_log_event()
891 cs->needs_update = true; in myrs_log_event()
915 if (cs->disable_enc_msg) in myrs_log_event()
940 struct myrs_hba *cs = shost_priv(sdev->host); in raid_state_show() local
946 if (sdev->channel >= cs->ctlr_info->physchan_present) { in raid_state_show()
975 struct myrs_hba *cs = shost_priv(sdev->host); in raid_state_store() local
992 if (sdev->channel < cs->ctlr_info->physchan_present) { in raid_state_store()
1003 status = myrs_translate_pdev(cs, sdev->channel, sdev->id, in raid_state_store()
1019 mutex_lock(&cs->dcmd_mutex); in raid_state_store()
1020 cmd_blk = &cs->dcmd_blk; in raid_state_store()
1030 myrs_exec_cmd(cs, cmd_blk); in raid_state_store()
1032 mutex_unlock(&cs->dcmd_mutex); in raid_state_store()
1034 if (sdev->channel < cs->ctlr_info->physchan_present) { in raid_state_store()
1059 struct myrs_hba *cs = shost_priv(sdev->host); in raid_level_show() local
1065 if (sdev->channel >= cs->ctlr_info->physchan_present) { in raid_level_show()
1085 struct myrs_hba *cs = shost_priv(sdev->host); in rebuild_show() local
1090 if (sdev->channel < cs->ctlr_info->physchan_present) in rebuild_show()
1095 status = myrs_get_ldev_info(cs, ldev_num, ldev_info); in rebuild_show()
1114 struct myrs_hba *cs = shost_priv(sdev->host); in rebuild_store() local
1122 if (sdev->channel < cs->ctlr_info->physchan_present) in rebuild_store()
1134 status = myrs_get_ldev_info(cs, ldev_num, ldev_info); in rebuild_store()
1153 mutex_lock(&cs->dcmd_mutex); in rebuild_store()
1154 cmd_blk = &cs->dcmd_blk; in rebuild_store()
1168 myrs_exec_cmd(cs, cmd_blk); in rebuild_store()
1170 mutex_unlock(&cs->dcmd_mutex); in rebuild_store()
1190 struct myrs_hba *cs = shost_priv(sdev->host); in consistency_check_show() local
1194 if (sdev->channel < cs->ctlr_info->physchan_present) in consistency_check_show()
1201 myrs_get_ldev_info(cs, ldev_num, ldev_info); in consistency_check_show()
1214 struct myrs_hba *cs = shost_priv(sdev->host); in consistency_check_store() local
1222 if (sdev->channel < cs->ctlr_info->physchan_present) in consistency_check_store()
1234 status = myrs_get_ldev_info(cs, ldev_num, ldev_info); in consistency_check_store()
1254 mutex_lock(&cs->dcmd_mutex); in consistency_check_store()
1255 cmd_blk = &cs->dcmd_blk; in consistency_check_store()
1271 myrs_exec_cmd(cs, cmd_blk); in consistency_check_store()
1273 mutex_unlock(&cs->dcmd_mutex); in consistency_check_store()
1303 struct myrs_hba *cs = shost_priv(shost); in serial_show() local
1306 memcpy(serial, cs->ctlr_info->serial_number, 16); in serial_show()
1316 struct myrs_hba *cs = shost_priv(shost); in ctlr_num_show() local
1318 return snprintf(buf, 20, "%d\n", cs->host->host_no); in ctlr_num_show()
1339 struct myrs_hba *cs = shost_priv(shost); in processor_show() local
1343 struct myrs_ctlr_info *info = cs->ctlr_info; in processor_show()
1391 struct myrs_hba *cs = shost_priv(shost); in model_show() local
1393 return snprintf(buf, 28, "%s\n", cs->model_name); in model_show()
1401 struct myrs_hba *cs = shost_priv(shost); in ctlr_type_show() local
1403 return snprintf(buf, 4, "%d\n", cs->ctlr_info->ctlr_type); in ctlr_type_show()
1411 struct myrs_hba *cs = shost_priv(shost); in cache_size_show() local
1413 return snprintf(buf, 8, "%d MB\n", cs->ctlr_info->cache_size_mb); in cache_size_show()
1421 struct myrs_hba *cs = shost_priv(shost); in firmware_show() local
1424 cs->ctlr_info->fw_major_version, in firmware_show()
1425 cs->ctlr_info->fw_minor_version, in firmware_show()
1426 cs->ctlr_info->fw_turn_number); in firmware_show()
1434 struct myrs_hba *cs = shost_priv(shost); in discovery_store() local
1439 mutex_lock(&cs->dcmd_mutex); in discovery_store()
1440 cmd_blk = &cs->dcmd_blk; in discovery_store()
1448 myrs_exec_cmd(cs, cmd_blk); in discovery_store()
1450 mutex_unlock(&cs->dcmd_mutex); in discovery_store()
1458 cs->next_evseq = 0; in discovery_store()
1459 cs->needs_update = true; in discovery_store()
1460 queue_delayed_work(cs->work_q, &cs->monitor_work, 1); in discovery_store()
1461 flush_delayed_work(&cs->monitor_work); in discovery_store()
1472 struct myrs_hba *cs = shost_priv(shost); in flush_cache_store() local
1475 status = myrs_dev_op(cs, MYRS_IOCTL_FLUSH_DEVICE_DATA, in flush_cache_store()
1491 struct myrs_hba *cs = shost_priv(shost); in disable_enclosure_messages_show() local
1493 return snprintf(buf, 3, "%d\n", cs->disable_enc_msg); in disable_enclosure_messages_show()
1500 struct myrs_hba *cs = shost_priv(sdev->host); in disable_enclosure_messages_store() local
1510 cs->disable_enc_msg = value; in disable_enclosure_messages_store()
1537 struct myrs_hba *cs = shost_priv(shost); in myrs_host_reset() local
1539 cs->reset(cs->io_base); in myrs_host_reset()
1543 static void myrs_mode_sense(struct myrs_hba *cs, struct scsi_cmnd *scmd, in myrs_mode_sense() argument
1590 struct myrs_hba *cs = shost_priv(shost); in myrs_queuecommand() local
1612 if (scmd->device->channel >= cs->ctlr_info->physchan_present) { in myrs_queuecommand()
1620 myrs_mode_sense(cs, scmd, ldev_info); in myrs_queuecommand()
1630 cmd_blk->sense = dma_pool_alloc(cs->sense_pool, GFP_ATOMIC, in myrs_queuecommand()
1638 if (scmd->device->channel >= cs->ctlr_info->physchan_present) { in myrs_queuecommand()
1674 cmd_blk->dcdb = dma_pool_alloc(cs->dcdb_pool, GFP_ATOMIC, in myrs_queuecommand()
1677 dma_pool_free(cs->sense_pool, cmd_blk->sense, in myrs_queuecommand()
1684 if (scmd->device->channel >= cs->ctlr_info->physchan_present) { in myrs_queuecommand()
1731 hw_sgl = dma_pool_alloc(cs->sg_pool, GFP_ATOMIC, in myrs_queuecommand()
1735 dma_pool_free(cs->dcdb_pool, in myrs_queuecommand()
1741 dma_pool_free(cs->sense_pool, in myrs_queuecommand()
1772 spin_lock_irqsave(&cs->queue_lock, flags); in myrs_queuecommand()
1773 myrs_qcmd(cs, cmd_blk); in myrs_queuecommand()
1774 spin_unlock_irqrestore(&cs->queue_lock, flags); in myrs_queuecommand()
1779 static unsigned short myrs_translate_ldev(struct myrs_hba *cs, in myrs_translate_ldev() argument
1784 sdev->channel - cs->ctlr_info->physchan_present; in myrs_translate_ldev()
1793 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_slave_alloc() local
1799 if (sdev->channel >= cs->ctlr_info->physchan_present) { in myrs_slave_alloc()
1806 ldev_num = myrs_translate_ldev(cs, sdev); in myrs_slave_alloc()
1812 status = myrs_get_ldev_info(cs, ldev_num, ldev_info); in myrs_slave_alloc()
1874 status = myrs_get_pdev_info(cs, sdev->channel, in myrs_slave_alloc()
1889 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_slave_configure() local
1895 if (sdev->channel < cs->ctlr_info->physchan_present) { in myrs_slave_configure()
1939 struct myrs_hba *cs; in myrs_alloc_host() local
1947 cs = shost_priv(shost); in myrs_alloc_host()
1948 mutex_init(&cs->dcmd_mutex); in myrs_alloc_host()
1949 mutex_init(&cs->cinfo_mutex); in myrs_alloc_host()
1950 cs->host = shost; in myrs_alloc_host()
1952 return cs; in myrs_alloc_host()
1967 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_is_raid() local
1969 return (sdev->channel >= cs->ctlr_info->physchan_present) ? 1 : 0; in myrs_is_raid()
1980 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_get_resync() local
1984 if (sdev->channel < cs->ctlr_info->physchan_present || !ldev_info) in myrs_get_resync()
1989 myrs_get_ldev_info(cs, ldev_num, ldev_info); in myrs_get_resync()
2004 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_get_state() local
2008 if (sdev->channel < cs->ctlr_info->physchan_present || !ldev_info) in myrs_get_state()
2043 static void myrs_flush_cache(struct myrs_hba *cs) in myrs_flush_cache() argument
2045 myrs_dev_op(cs, MYRS_IOCTL_FLUSH_DEVICE_DATA, MYRS_RAID_CONTROLLER); in myrs_flush_cache()
2048 static void myrs_handle_scsi(struct myrs_hba *cs, struct myrs_cmdblk *cmd_blk, in myrs_handle_scsi() argument
2066 dma_pool_free(cs->sense_pool, cmd_blk->sense, in myrs_handle_scsi()
2072 dma_pool_free(cs->dcdb_pool, cmd_blk->dcdb, in myrs_handle_scsi()
2078 dma_pool_free(cs->sg_pool, cmd_blk->sgl, in myrs_handle_scsi()
2093 static void myrs_handle_cmdblk(struct myrs_hba *cs, struct myrs_cmdblk *cmd_blk) in myrs_handle_cmdblk() argument
2106 struct myrs_hba *cs = container_of(work, struct myrs_hba, in myrs_monitor() local
2108 struct Scsi_Host *shost = cs->host; in myrs_monitor()
2109 struct myrs_ctlr_info *info = cs->ctlr_info; in myrs_monitor()
2110 unsigned int epoch = cs->fwstat_buf->epoch; in myrs_monitor()
2116 status = myrs_get_fwstatus(cs); in myrs_monitor()
2118 if (cs->needs_update) { in myrs_monitor()
2119 cs->needs_update = false; in myrs_monitor()
2120 mutex_lock(&cs->cinfo_mutex); in myrs_monitor()
2121 status = myrs_get_ctlr_info(cs); in myrs_monitor()
2122 mutex_unlock(&cs->cinfo_mutex); in myrs_monitor()
2124 if (cs->fwstat_buf->next_evseq - cs->next_evseq > 0) { in myrs_monitor()
2125 status = myrs_get_event(cs, cs->next_evseq, in myrs_monitor()
2126 cs->event_buf); in myrs_monitor()
2128 myrs_log_event(cs, cs->event_buf); in myrs_monitor()
2129 cs->next_evseq++; in myrs_monitor()
2134 if (time_after(jiffies, cs->secondary_monitor_time in myrs_monitor()
2136 cs->secondary_monitor_time = jiffies; in myrs_monitor()
2156 myrs_get_ldev_info(cs, ldev_num, ldev_info); in myrs_monitor()
2158 cs->needs_update = true; in myrs_monitor()
2160 if (epoch == cs->epoch && in myrs_monitor()
2161 cs->fwstat_buf->next_evseq == cs->next_evseq && in myrs_monitor()
2162 (cs->needs_update == false || in myrs_monitor()
2163 time_before(jiffies, cs->primary_monitor_time in myrs_monitor()
2169 cs->primary_monitor_time = jiffies; in myrs_monitor()
2170 queue_delayed_work(cs->work_q, &cs->monitor_work, interval); in myrs_monitor()
2173 static bool myrs_create_mempools(struct pci_dev *pdev, struct myrs_hba *cs) in myrs_create_mempools() argument
2175 struct Scsi_Host *shost = cs->host; in myrs_create_mempools()
2180 cs->sg_pool = dma_pool_create("myrs_sg", &pdev->dev, in myrs_create_mempools()
2182 if (cs->sg_pool == NULL) { in myrs_create_mempools()
2188 cs->sense_pool = dma_pool_create("myrs_sense", &pdev->dev, in myrs_create_mempools()
2190 if (cs->sense_pool == NULL) { in myrs_create_mempools()
2191 dma_pool_destroy(cs->sg_pool); in myrs_create_mempools()
2192 cs->sg_pool = NULL; in myrs_create_mempools()
2198 cs->dcdb_pool = dma_pool_create("myrs_dcdb", &pdev->dev, in myrs_create_mempools()
2201 if (!cs->dcdb_pool) { in myrs_create_mempools()
2202 dma_pool_destroy(cs->sg_pool); in myrs_create_mempools()
2203 cs->sg_pool = NULL; in myrs_create_mempools()
2204 dma_pool_destroy(cs->sense_pool); in myrs_create_mempools()
2205 cs->sense_pool = NULL; in myrs_create_mempools()
2211 snprintf(cs->work_q_name, sizeof(cs->work_q_name), in myrs_create_mempools()
2213 cs->work_q = create_singlethread_workqueue(cs->work_q_name); in myrs_create_mempools()
2214 if (!cs->work_q) { in myrs_create_mempools()
2215 dma_pool_destroy(cs->dcdb_pool); in myrs_create_mempools()
2216 cs->dcdb_pool = NULL; in myrs_create_mempools()
2217 dma_pool_destroy(cs->sg_pool); in myrs_create_mempools()
2218 cs->sg_pool = NULL; in myrs_create_mempools()
2219 dma_pool_destroy(cs->sense_pool); in myrs_create_mempools()
2220 cs->sense_pool = NULL; in myrs_create_mempools()
2227 INIT_DELAYED_WORK(&cs->monitor_work, myrs_monitor); in myrs_create_mempools()
2228 queue_delayed_work(cs->work_q, &cs->monitor_work, 1); in myrs_create_mempools()
2233 static void myrs_destroy_mempools(struct myrs_hba *cs) in myrs_destroy_mempools() argument
2235 cancel_delayed_work_sync(&cs->monitor_work); in myrs_destroy_mempools()
2236 destroy_workqueue(cs->work_q); in myrs_destroy_mempools()
2238 dma_pool_destroy(cs->sg_pool); in myrs_destroy_mempools()
2239 dma_pool_destroy(cs->dcdb_pool); in myrs_destroy_mempools()
2240 dma_pool_destroy(cs->sense_pool); in myrs_destroy_mempools()
2243 static void myrs_unmap(struct myrs_hba *cs) in myrs_unmap() argument
2245 kfree(cs->event_buf); in myrs_unmap()
2246 kfree(cs->ctlr_info); in myrs_unmap()
2247 if (cs->fwstat_buf) { in myrs_unmap()
2248 dma_free_coherent(&cs->pdev->dev, sizeof(struct myrs_fwstat), in myrs_unmap()
2249 cs->fwstat_buf, cs->fwstat_addr); in myrs_unmap()
2250 cs->fwstat_buf = NULL; in myrs_unmap()
2252 if (cs->first_stat_mbox) { in myrs_unmap()
2253 dma_free_coherent(&cs->pdev->dev, cs->stat_mbox_size, in myrs_unmap()
2254 cs->first_stat_mbox, cs->stat_mbox_addr); in myrs_unmap()
2255 cs->first_stat_mbox = NULL; in myrs_unmap()
2257 if (cs->first_cmd_mbox) { in myrs_unmap()
2258 dma_free_coherent(&cs->pdev->dev, cs->cmd_mbox_size, in myrs_unmap()
2259 cs->first_cmd_mbox, cs->cmd_mbox_addr); in myrs_unmap()
2260 cs->first_cmd_mbox = NULL; in myrs_unmap()
2264 static void myrs_cleanup(struct myrs_hba *cs) in myrs_cleanup() argument
2266 struct pci_dev *pdev = cs->pdev; in myrs_cleanup()
2269 myrs_unmap(cs); in myrs_cleanup()
2271 if (cs->mmio_base) { in myrs_cleanup()
2272 cs->disable_intr(cs); in myrs_cleanup()
2273 iounmap(cs->mmio_base); in myrs_cleanup()
2274 cs->mmio_base = NULL; in myrs_cleanup()
2276 if (cs->irq) in myrs_cleanup()
2277 free_irq(cs->irq, cs); in myrs_cleanup()
2278 if (cs->io_addr) in myrs_cleanup()
2279 release_region(cs->io_addr, 0x80); in myrs_cleanup()
2282 scsi_host_put(cs->host); in myrs_cleanup()
2292 struct myrs_hba *cs = NULL; in myrs_detect() local
2294 cs = myrs_alloc_host(pdev, entry); in myrs_detect()
2295 if (!cs) { in myrs_detect()
2299 cs->pdev = pdev; in myrs_detect()
2304 cs->pci_addr = pci_resource_start(pdev, 0); in myrs_detect()
2306 pci_set_drvdata(pdev, cs); in myrs_detect()
2307 spin_lock_init(&cs->queue_lock); in myrs_detect()
2311 cs->mmio_base = ioremap(cs->pci_addr & PAGE_MASK, mmio_size); in myrs_detect()
2312 if (cs->mmio_base == NULL) { in myrs_detect()
2318 cs->io_base = cs->mmio_base + (cs->pci_addr & ~PAGE_MASK); in myrs_detect()
2319 if (privdata->hw_init(pdev, cs, cs->io_base)) in myrs_detect()
2323 if (request_irq(pdev->irq, irq_handler, IRQF_SHARED, "myrs", cs) < 0) { in myrs_detect()
2328 cs->irq = pdev->irq; in myrs_detect()
2329 return cs; in myrs_detect()
2334 myrs_cleanup(cs); in myrs_detect()
2344 static bool myrs_err_status(struct myrs_hba *cs, unsigned char status, in myrs_err_status() argument
2347 struct pci_dev *pdev = cs->pdev; in myrs_err_status()
2538 struct myrs_hba *cs, void __iomem *base) in DAC960_GEM_hw_init() argument
2550 myrs_err_status(cs, status, parm0, parm1)) in DAC960_GEM_hw_init()
2560 if (!myrs_enable_mmio_mbox(cs, DAC960_GEM_mbox_init)) { in DAC960_GEM_hw_init()
2567 cs->write_cmd_mbox = DAC960_GEM_write_cmd_mbox; in DAC960_GEM_hw_init()
2568 cs->get_cmd_mbox = DAC960_GEM_mem_mbox_new_cmd; in DAC960_GEM_hw_init()
2569 cs->disable_intr = DAC960_GEM_disable_intr; in DAC960_GEM_hw_init()
2570 cs->reset = DAC960_GEM_reset_ctrl; in DAC960_GEM_hw_init()
2576 struct myrs_hba *cs = arg; in DAC960_GEM_intr_handler() local
2577 void __iomem *base = cs->io_base; in DAC960_GEM_intr_handler()
2581 spin_lock_irqsave(&cs->queue_lock, flags); in DAC960_GEM_intr_handler()
2583 next_stat_mbox = cs->next_stat_mbox; in DAC960_GEM_intr_handler()
2590 cmd_blk = &cs->dcmd_blk; in DAC960_GEM_intr_handler()
2592 cmd_blk = &cs->mcmd_blk; in DAC960_GEM_intr_handler()
2594 scmd = scsi_host_find_tag(cs->host, id - 3); in DAC960_GEM_intr_handler()
2603 dev_err(&cs->pdev->dev, in DAC960_GEM_intr_handler()
2607 if (++next_stat_mbox > cs->last_stat_mbox) in DAC960_GEM_intr_handler()
2608 next_stat_mbox = cs->first_stat_mbox; in DAC960_GEM_intr_handler()
2612 myrs_handle_cmdblk(cs, cmd_blk); in DAC960_GEM_intr_handler()
2614 myrs_handle_scsi(cs, cmd_blk, scmd); in DAC960_GEM_intr_handler()
2617 cs->next_stat_mbox = next_stat_mbox; in DAC960_GEM_intr_handler()
2618 spin_unlock_irqrestore(&cs->queue_lock, flags); in DAC960_GEM_intr_handler()
2757 struct myrs_hba *cs, void __iomem *base) in DAC960_BA_hw_init() argument
2769 myrs_err_status(cs, status, parm0, parm1)) in DAC960_BA_hw_init()
2779 if (!myrs_enable_mmio_mbox(cs, DAC960_BA_mbox_init)) { in DAC960_BA_hw_init()
2786 cs->write_cmd_mbox = DAC960_BA_write_cmd_mbox; in DAC960_BA_hw_init()
2787 cs->get_cmd_mbox = DAC960_BA_mem_mbox_new_cmd; in DAC960_BA_hw_init()
2788 cs->disable_intr = DAC960_BA_disable_intr; in DAC960_BA_hw_init()
2789 cs->reset = DAC960_BA_reset_ctrl; in DAC960_BA_hw_init()
2795 struct myrs_hba *cs = arg; in DAC960_BA_intr_handler() local
2796 void __iomem *base = cs->io_base; in DAC960_BA_intr_handler()
2800 spin_lock_irqsave(&cs->queue_lock, flags); in DAC960_BA_intr_handler()
2802 next_stat_mbox = cs->next_stat_mbox; in DAC960_BA_intr_handler()
2809 cmd_blk = &cs->dcmd_blk; in DAC960_BA_intr_handler()
2811 cmd_blk = &cs->mcmd_blk; in DAC960_BA_intr_handler()
2813 scmd = scsi_host_find_tag(cs->host, id - 3); in DAC960_BA_intr_handler()
2822 dev_err(&cs->pdev->dev, in DAC960_BA_intr_handler()
2826 if (++next_stat_mbox > cs->last_stat_mbox) in DAC960_BA_intr_handler()
2827 next_stat_mbox = cs->first_stat_mbox; in DAC960_BA_intr_handler()
2831 myrs_handle_cmdblk(cs, cmd_blk); in DAC960_BA_intr_handler()
2833 myrs_handle_scsi(cs, cmd_blk, scmd); in DAC960_BA_intr_handler()
2836 cs->next_stat_mbox = next_stat_mbox; in DAC960_BA_intr_handler()
2837 spin_unlock_irqrestore(&cs->queue_lock, flags); in DAC960_BA_intr_handler()
2975 struct myrs_hba *cs, void __iomem *base) in DAC960_LP_hw_init() argument
2987 myrs_err_status(cs, status, parm0, parm1)) in DAC960_LP_hw_init()
2997 if (!myrs_enable_mmio_mbox(cs, DAC960_LP_mbox_init)) { in DAC960_LP_hw_init()
3004 cs->write_cmd_mbox = DAC960_LP_write_cmd_mbox; in DAC960_LP_hw_init()
3005 cs->get_cmd_mbox = DAC960_LP_mem_mbox_new_cmd; in DAC960_LP_hw_init()
3006 cs->disable_intr = DAC960_LP_disable_intr; in DAC960_LP_hw_init()
3007 cs->reset = DAC960_LP_reset_ctrl; in DAC960_LP_hw_init()
3014 struct myrs_hba *cs = arg; in DAC960_LP_intr_handler() local
3015 void __iomem *base = cs->io_base; in DAC960_LP_intr_handler()
3019 spin_lock_irqsave(&cs->queue_lock, flags); in DAC960_LP_intr_handler()
3021 next_stat_mbox = cs->next_stat_mbox; in DAC960_LP_intr_handler()
3028 cmd_blk = &cs->dcmd_blk; in DAC960_LP_intr_handler()
3030 cmd_blk = &cs->mcmd_blk; in DAC960_LP_intr_handler()
3032 scmd = scsi_host_find_tag(cs->host, id - 3); in DAC960_LP_intr_handler()
3041 dev_err(&cs->pdev->dev, in DAC960_LP_intr_handler()
3045 if (++next_stat_mbox > cs->last_stat_mbox) in DAC960_LP_intr_handler()
3046 next_stat_mbox = cs->first_stat_mbox; in DAC960_LP_intr_handler()
3050 myrs_handle_cmdblk(cs, cmd_blk); in DAC960_LP_intr_handler()
3052 myrs_handle_scsi(cs, cmd_blk, scmd); in DAC960_LP_intr_handler()
3055 cs->next_stat_mbox = next_stat_mbox; in DAC960_LP_intr_handler()
3056 spin_unlock_irqrestore(&cs->queue_lock, flags); in DAC960_LP_intr_handler()
3072 struct myrs_hba *cs; in myrs_probe() local
3075 cs = myrs_detect(dev, entry); in myrs_probe()
3076 if (!cs) in myrs_probe()
3079 ret = myrs_get_config(cs); in myrs_probe()
3081 myrs_cleanup(cs); in myrs_probe()
3085 if (!myrs_create_mempools(dev, cs)) { in myrs_probe()
3090 ret = scsi_add_host(cs->host, &dev->dev); in myrs_probe()
3093 myrs_destroy_mempools(cs); in myrs_probe()
3096 scsi_scan_host(cs->host); in myrs_probe()
3099 myrs_cleanup(cs); in myrs_probe()
3106 struct myrs_hba *cs = pci_get_drvdata(pdev); in myrs_remove() local
3108 if (cs == NULL) in myrs_remove()
3111 shost_printk(KERN_NOTICE, cs->host, "Flushing Cache..."); in myrs_remove()
3112 myrs_flush_cache(cs); in myrs_remove()
3113 myrs_destroy_mempools(cs); in myrs_remove()
3114 myrs_cleanup(cs); in myrs_remove()