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), GFP_KERNEL); in myrs_enable_mmio_mbox()
542 if (!cs->ctlr_info) in myrs_enable_mmio_mbox()
545 cs->event_buf = kzalloc(sizeof(struct myrs_event), GFP_KERNEL); in myrs_enable_mmio_mbox()
546 if (!cs->event_buf) in myrs_enable_mmio_mbox()
563 mbox->set_mbox.fwstat_buf_addr = cs->fwstat_addr; in myrs_enable_mmio_mbox()
564 mbox->set_mbox.first_cmd_mbox_addr = cs->cmd_mbox_addr; in myrs_enable_mmio_mbox()
565 mbox->set_mbox.first_stat_mbox_addr = cs->stat_mbox_addr; in myrs_enable_mmio_mbox()
580 static int myrs_get_config(struct myrs_hba *cs) in myrs_get_config() argument
582 struct myrs_ctlr_info *info = cs->ctlr_info; in myrs_get_config()
583 struct Scsi_Host *shost = cs->host; in myrs_get_config()
590 mutex_lock(&cs->cinfo_mutex); in myrs_get_config()
591 status = myrs_get_ctlr_info(cs); in myrs_get_config()
592 mutex_unlock(&cs->cinfo_mutex); in myrs_get_config()
608 strcpy(cs->model_name, "DAC960 "); in myrs_get_config()
609 strcat(cs->model_name, model); in myrs_get_config()
811 static void myrs_log_event(struct myrs_hba *cs, struct myrs_event *ev) in myrs_log_event() argument
816 struct Scsi_Host *shost = cs->host; in myrs_log_event()
856 sdev->channel < cs->ctlr_info->physchan_present) { in myrs_log_event()
883 cs->needs_update = true; in myrs_log_event()
889 cs->needs_update = true; in myrs_log_event()
913 if (cs->disable_enc_msg) in myrs_log_event()
938 struct myrs_hba *cs = shost_priv(sdev->host); in raid_state_show() local
944 if (sdev->channel >= cs->ctlr_info->physchan_present) { in raid_state_show()
973 struct myrs_hba *cs = shost_priv(sdev->host); in raid_state_store() local
990 if (sdev->channel < cs->ctlr_info->physchan_present) { in raid_state_store()
1001 status = myrs_translate_pdev(cs, sdev->channel, sdev->id, in raid_state_store()
1017 mutex_lock(&cs->dcmd_mutex); in raid_state_store()
1018 cmd_blk = &cs->dcmd_blk; in raid_state_store()
1028 myrs_exec_cmd(cs, cmd_blk); in raid_state_store()
1030 mutex_unlock(&cs->dcmd_mutex); in raid_state_store()
1032 if (sdev->channel < cs->ctlr_info->physchan_present) { in raid_state_store()
1057 struct myrs_hba *cs = shost_priv(sdev->host); in raid_level_show() local
1063 if (sdev->channel >= cs->ctlr_info->physchan_present) { in raid_level_show()
1083 struct myrs_hba *cs = shost_priv(sdev->host); in rebuild_show() local
1088 if (sdev->channel < cs->ctlr_info->physchan_present) in rebuild_show()
1093 status = myrs_get_ldev_info(cs, ldev_num, ldev_info); in rebuild_show()
1112 struct myrs_hba *cs = shost_priv(sdev->host); in rebuild_store() local
1120 if (sdev->channel < cs->ctlr_info->physchan_present) in rebuild_store()
1132 status = myrs_get_ldev_info(cs, ldev_num, ldev_info); in rebuild_store()
1151 mutex_lock(&cs->dcmd_mutex); in rebuild_store()
1152 cmd_blk = &cs->dcmd_blk; in rebuild_store()
1166 myrs_exec_cmd(cs, cmd_blk); in rebuild_store()
1168 mutex_unlock(&cs->dcmd_mutex); in rebuild_store()
1188 struct myrs_hba *cs = shost_priv(sdev->host); in consistency_check_show() local
1192 if (sdev->channel < cs->ctlr_info->physchan_present) in consistency_check_show()
1199 myrs_get_ldev_info(cs, ldev_num, ldev_info); in consistency_check_show()
1212 struct myrs_hba *cs = shost_priv(sdev->host); in consistency_check_store() local
1220 if (sdev->channel < cs->ctlr_info->physchan_present) in consistency_check_store()
1232 status = myrs_get_ldev_info(cs, ldev_num, ldev_info); in consistency_check_store()
1252 mutex_lock(&cs->dcmd_mutex); in consistency_check_store()
1253 cmd_blk = &cs->dcmd_blk; in consistency_check_store()
1269 myrs_exec_cmd(cs, cmd_blk); in consistency_check_store()
1271 mutex_unlock(&cs->dcmd_mutex); in consistency_check_store()
1301 struct myrs_hba *cs = shost_priv(shost); in serial_show() local
1304 memcpy(serial, cs->ctlr_info->serial_number, 16); in serial_show()
1314 struct myrs_hba *cs = shost_priv(shost); in ctlr_num_show() local
1316 return snprintf(buf, 20, "%d\n", cs->host->host_no); in ctlr_num_show()
1337 struct myrs_hba *cs = shost_priv(shost); in processor_show() local
1341 struct myrs_ctlr_info *info = cs->ctlr_info; in processor_show()
1389 struct myrs_hba *cs = shost_priv(shost); in model_show() local
1391 return snprintf(buf, 28, "%s\n", cs->model_name); in model_show()
1399 struct myrs_hba *cs = shost_priv(shost); in ctlr_type_show() local
1401 return snprintf(buf, 4, "%d\n", cs->ctlr_info->ctlr_type); in ctlr_type_show()
1409 struct myrs_hba *cs = shost_priv(shost); in cache_size_show() local
1411 return snprintf(buf, 8, "%d MB\n", cs->ctlr_info->cache_size_mb); in cache_size_show()
1419 struct myrs_hba *cs = shost_priv(shost); in firmware_show() local
1422 cs->ctlr_info->fw_major_version, in firmware_show()
1423 cs->ctlr_info->fw_minor_version, in firmware_show()
1424 cs->ctlr_info->fw_turn_number); in firmware_show()
1432 struct myrs_hba *cs = shost_priv(shost); in discovery_store() local
1437 mutex_lock(&cs->dcmd_mutex); in discovery_store()
1438 cmd_blk = &cs->dcmd_blk; in discovery_store()
1446 myrs_exec_cmd(cs, cmd_blk); in discovery_store()
1448 mutex_unlock(&cs->dcmd_mutex); in discovery_store()
1456 cs->next_evseq = 0; in discovery_store()
1457 cs->needs_update = true; in discovery_store()
1458 queue_delayed_work(cs->work_q, &cs->monitor_work, 1); in discovery_store()
1459 flush_delayed_work(&cs->monitor_work); in discovery_store()
1470 struct myrs_hba *cs = shost_priv(shost); in flush_cache_store() local
1473 status = myrs_dev_op(cs, MYRS_IOCTL_FLUSH_DEVICE_DATA, in flush_cache_store()
1489 struct myrs_hba *cs = shost_priv(shost); in disable_enclosure_messages_show() local
1491 return snprintf(buf, 3, "%d\n", cs->disable_enc_msg); in disable_enclosure_messages_show()
1498 struct myrs_hba *cs = shost_priv(sdev->host); in disable_enclosure_messages_store() local
1508 cs->disable_enc_msg = value; in disable_enclosure_messages_store()
1535 struct myrs_hba *cs = shost_priv(shost); in myrs_host_reset() local
1537 cs->reset(cs->io_base); in myrs_host_reset()
1541 static void myrs_mode_sense(struct myrs_hba *cs, struct scsi_cmnd *scmd, in myrs_mode_sense() argument
1588 struct myrs_hba *cs = shost_priv(shost); in myrs_queuecommand() local
1610 if (scmd->device->channel >= cs->ctlr_info->physchan_present) { in myrs_queuecommand()
1618 myrs_mode_sense(cs, scmd, ldev_info); in myrs_queuecommand()
1628 cmd_blk->sense = dma_pool_alloc(cs->sense_pool, GFP_ATOMIC, in myrs_queuecommand()
1636 if (scmd->device->channel >= cs->ctlr_info->physchan_present) { in myrs_queuecommand()
1672 cmd_blk->dcdb = dma_pool_alloc(cs->dcdb_pool, GFP_ATOMIC, in myrs_queuecommand()
1675 dma_pool_free(cs->sense_pool, cmd_blk->sense, in myrs_queuecommand()
1682 if (scmd->device->channel >= cs->ctlr_info->physchan_present) { in myrs_queuecommand()
1729 hw_sgl = dma_pool_alloc(cs->sg_pool, GFP_ATOMIC, in myrs_queuecommand()
1733 dma_pool_free(cs->dcdb_pool, in myrs_queuecommand()
1739 dma_pool_free(cs->sense_pool, in myrs_queuecommand()
1770 spin_lock_irqsave(&cs->queue_lock, flags); in myrs_queuecommand()
1771 myrs_qcmd(cs, cmd_blk); in myrs_queuecommand()
1772 spin_unlock_irqrestore(&cs->queue_lock, flags); in myrs_queuecommand()
1777 static unsigned short myrs_translate_ldev(struct myrs_hba *cs, in myrs_translate_ldev() argument
1782 sdev->channel - cs->ctlr_info->physchan_present; in myrs_translate_ldev()
1791 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_slave_alloc() local
1797 if (sdev->channel >= cs->ctlr_info->physchan_present) { in myrs_slave_alloc()
1804 ldev_num = myrs_translate_ldev(cs, sdev); in myrs_slave_alloc()
1810 status = myrs_get_ldev_info(cs, ldev_num, ldev_info); in myrs_slave_alloc()
1872 status = myrs_get_pdev_info(cs, sdev->channel, in myrs_slave_alloc()
1887 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_slave_configure() local
1893 if (sdev->channel < cs->ctlr_info->physchan_present) { in myrs_slave_configure()
1937 struct myrs_hba *cs; in myrs_alloc_host() local
1945 cs = shost_priv(shost); in myrs_alloc_host()
1946 mutex_init(&cs->dcmd_mutex); in myrs_alloc_host()
1947 mutex_init(&cs->cinfo_mutex); in myrs_alloc_host()
1948 cs->host = shost; in myrs_alloc_host()
1950 return cs; in myrs_alloc_host()
1965 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_is_raid() local
1967 return (sdev->channel >= cs->ctlr_info->physchan_present) ? 1 : 0; in myrs_is_raid()
1978 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_get_resync() local
1982 if (sdev->channel < cs->ctlr_info->physchan_present || !ldev_info) in myrs_get_resync()
1987 myrs_get_ldev_info(cs, ldev_num, ldev_info); in myrs_get_resync()
2002 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_get_state() local
2006 if (sdev->channel < cs->ctlr_info->physchan_present || !ldev_info) in myrs_get_state()
2041 static void myrs_flush_cache(struct myrs_hba *cs) in myrs_flush_cache() argument
2043 myrs_dev_op(cs, MYRS_IOCTL_FLUSH_DEVICE_DATA, MYRS_RAID_CONTROLLER); in myrs_flush_cache()
2046 static void myrs_handle_scsi(struct myrs_hba *cs, struct myrs_cmdblk *cmd_blk, in myrs_handle_scsi() argument
2064 dma_pool_free(cs->sense_pool, cmd_blk->sense, in myrs_handle_scsi()
2070 dma_pool_free(cs->dcdb_pool, cmd_blk->dcdb, in myrs_handle_scsi()
2076 dma_pool_free(cs->sg_pool, cmd_blk->sgl, in myrs_handle_scsi()
2091 static void myrs_handle_cmdblk(struct myrs_hba *cs, struct myrs_cmdblk *cmd_blk) in myrs_handle_cmdblk() argument
2104 struct myrs_hba *cs = container_of(work, struct myrs_hba, in myrs_monitor() local
2106 struct Scsi_Host *shost = cs->host; in myrs_monitor()
2107 struct myrs_ctlr_info *info = cs->ctlr_info; in myrs_monitor()
2108 unsigned int epoch = cs->fwstat_buf->epoch; in myrs_monitor()
2114 status = myrs_get_fwstatus(cs); in myrs_monitor()
2116 if (cs->needs_update) { in myrs_monitor()
2117 cs->needs_update = false; in myrs_monitor()
2118 mutex_lock(&cs->cinfo_mutex); in myrs_monitor()
2119 status = myrs_get_ctlr_info(cs); in myrs_monitor()
2120 mutex_unlock(&cs->cinfo_mutex); in myrs_monitor()
2122 if (cs->fwstat_buf->next_evseq - cs->next_evseq > 0) { in myrs_monitor()
2123 status = myrs_get_event(cs, cs->next_evseq, in myrs_monitor()
2124 cs->event_buf); in myrs_monitor()
2126 myrs_log_event(cs, cs->event_buf); in myrs_monitor()
2127 cs->next_evseq++; in myrs_monitor()
2132 if (time_after(jiffies, cs->secondary_monitor_time in myrs_monitor()
2134 cs->secondary_monitor_time = jiffies; in myrs_monitor()
2154 myrs_get_ldev_info(cs, ldev_num, ldev_info); in myrs_monitor()
2156 cs->needs_update = true; in myrs_monitor()
2158 if (epoch == cs->epoch && in myrs_monitor()
2159 cs->fwstat_buf->next_evseq == cs->next_evseq && in myrs_monitor()
2160 (cs->needs_update == false || in myrs_monitor()
2161 time_before(jiffies, cs->primary_monitor_time in myrs_monitor()
2167 cs->primary_monitor_time = jiffies; in myrs_monitor()
2168 queue_delayed_work(cs->work_q, &cs->monitor_work, interval); in myrs_monitor()
2171 static bool myrs_create_mempools(struct pci_dev *pdev, struct myrs_hba *cs) in myrs_create_mempools() argument
2173 struct Scsi_Host *shost = cs->host; in myrs_create_mempools()
2178 cs->sg_pool = dma_pool_create("myrs_sg", &pdev->dev, in myrs_create_mempools()
2180 if (cs->sg_pool == NULL) { in myrs_create_mempools()
2186 cs->sense_pool = dma_pool_create("myrs_sense", &pdev->dev, in myrs_create_mempools()
2188 if (cs->sense_pool == NULL) { in myrs_create_mempools()
2189 dma_pool_destroy(cs->sg_pool); in myrs_create_mempools()
2190 cs->sg_pool = NULL; in myrs_create_mempools()
2196 cs->dcdb_pool = dma_pool_create("myrs_dcdb", &pdev->dev, in myrs_create_mempools()
2199 if (!cs->dcdb_pool) { in myrs_create_mempools()
2200 dma_pool_destroy(cs->sg_pool); in myrs_create_mempools()
2201 cs->sg_pool = NULL; in myrs_create_mempools()
2202 dma_pool_destroy(cs->sense_pool); in myrs_create_mempools()
2203 cs->sense_pool = NULL; in myrs_create_mempools()
2209 snprintf(cs->work_q_name, sizeof(cs->work_q_name), in myrs_create_mempools()
2211 cs->work_q = create_singlethread_workqueue(cs->work_q_name); in myrs_create_mempools()
2212 if (!cs->work_q) { in myrs_create_mempools()
2213 dma_pool_destroy(cs->dcdb_pool); in myrs_create_mempools()
2214 cs->dcdb_pool = NULL; in myrs_create_mempools()
2215 dma_pool_destroy(cs->sg_pool); in myrs_create_mempools()
2216 cs->sg_pool = NULL; in myrs_create_mempools()
2217 dma_pool_destroy(cs->sense_pool); in myrs_create_mempools()
2218 cs->sense_pool = NULL; in myrs_create_mempools()
2225 INIT_DELAYED_WORK(&cs->monitor_work, myrs_monitor); in myrs_create_mempools()
2226 queue_delayed_work(cs->work_q, &cs->monitor_work, 1); in myrs_create_mempools()
2231 static void myrs_destroy_mempools(struct myrs_hba *cs) in myrs_destroy_mempools() argument
2233 cancel_delayed_work_sync(&cs->monitor_work); in myrs_destroy_mempools()
2234 destroy_workqueue(cs->work_q); in myrs_destroy_mempools()
2236 dma_pool_destroy(cs->sg_pool); in myrs_destroy_mempools()
2237 dma_pool_destroy(cs->dcdb_pool); in myrs_destroy_mempools()
2238 dma_pool_destroy(cs->sense_pool); in myrs_destroy_mempools()
2241 static void myrs_unmap(struct myrs_hba *cs) in myrs_unmap() argument
2243 kfree(cs->event_buf); in myrs_unmap()
2244 kfree(cs->ctlr_info); in myrs_unmap()
2245 if (cs->fwstat_buf) { in myrs_unmap()
2246 dma_free_coherent(&cs->pdev->dev, sizeof(struct myrs_fwstat), in myrs_unmap()
2247 cs->fwstat_buf, cs->fwstat_addr); in myrs_unmap()
2248 cs->fwstat_buf = NULL; in myrs_unmap()
2250 if (cs->first_stat_mbox) { in myrs_unmap()
2251 dma_free_coherent(&cs->pdev->dev, cs->stat_mbox_size, in myrs_unmap()
2252 cs->first_stat_mbox, cs->stat_mbox_addr); in myrs_unmap()
2253 cs->first_stat_mbox = NULL; in myrs_unmap()
2255 if (cs->first_cmd_mbox) { in myrs_unmap()
2256 dma_free_coherent(&cs->pdev->dev, cs->cmd_mbox_size, in myrs_unmap()
2257 cs->first_cmd_mbox, cs->cmd_mbox_addr); in myrs_unmap()
2258 cs->first_cmd_mbox = NULL; in myrs_unmap()
2262 static void myrs_cleanup(struct myrs_hba *cs) in myrs_cleanup() argument
2264 struct pci_dev *pdev = cs->pdev; in myrs_cleanup()
2267 myrs_unmap(cs); in myrs_cleanup()
2269 if (cs->mmio_base) { in myrs_cleanup()
2270 if (cs->disable_intr) in myrs_cleanup()
2271 cs->disable_intr(cs); in myrs_cleanup()
2272 iounmap(cs->mmio_base); in myrs_cleanup()
2273 cs->mmio_base = NULL; in myrs_cleanup()
2275 if (cs->irq) in myrs_cleanup()
2276 free_irq(cs->irq, cs); in myrs_cleanup()
2277 if (cs->io_addr) in myrs_cleanup()
2278 release_region(cs->io_addr, 0x80); in myrs_cleanup()
2281 scsi_host_put(cs->host); in myrs_cleanup()
2291 struct myrs_hba *cs = NULL; in myrs_detect() local
2293 cs = myrs_alloc_host(pdev, entry); in myrs_detect()
2294 if (!cs) { in myrs_detect()
2298 cs->pdev = pdev; in myrs_detect()
2303 cs->pci_addr = pci_resource_start(pdev, 0); in myrs_detect()
2305 pci_set_drvdata(pdev, cs); in myrs_detect()
2306 spin_lock_init(&cs->queue_lock); in myrs_detect()
2310 cs->mmio_base = ioremap(cs->pci_addr & PAGE_MASK, mmio_size); in myrs_detect()
2311 if (cs->mmio_base == NULL) { in myrs_detect()
2317 cs->io_base = cs->mmio_base + (cs->pci_addr & ~PAGE_MASK); in myrs_detect()
2318 if (privdata->hw_init(pdev, cs, cs->io_base)) in myrs_detect()
2322 if (request_irq(pdev->irq, irq_handler, IRQF_SHARED, "myrs", cs) < 0) { in myrs_detect()
2327 cs->irq = pdev->irq; in myrs_detect()
2328 return cs; in myrs_detect()
2333 myrs_cleanup(cs); in myrs_detect()
2343 static bool myrs_err_status(struct myrs_hba *cs, unsigned char status, in myrs_err_status() argument
2346 struct pci_dev *pdev = cs->pdev; in myrs_err_status()
2537 struct myrs_hba *cs, void __iomem *base) in DAC960_GEM_hw_init() argument
2549 myrs_err_status(cs, status, parm0, parm1)) in DAC960_GEM_hw_init()
2559 if (!myrs_enable_mmio_mbox(cs, DAC960_GEM_mbox_init)) { in DAC960_GEM_hw_init()
2566 cs->write_cmd_mbox = DAC960_GEM_write_cmd_mbox; in DAC960_GEM_hw_init()
2567 cs->get_cmd_mbox = DAC960_GEM_mem_mbox_new_cmd; in DAC960_GEM_hw_init()
2568 cs->disable_intr = DAC960_GEM_disable_intr; in DAC960_GEM_hw_init()
2569 cs->reset = DAC960_GEM_reset_ctrl; in DAC960_GEM_hw_init()
2575 struct myrs_hba *cs = arg; in DAC960_GEM_intr_handler() local
2576 void __iomem *base = cs->io_base; in DAC960_GEM_intr_handler()
2580 spin_lock_irqsave(&cs->queue_lock, flags); in DAC960_GEM_intr_handler()
2582 next_stat_mbox = cs->next_stat_mbox; in DAC960_GEM_intr_handler()
2589 cmd_blk = &cs->dcmd_blk; in DAC960_GEM_intr_handler()
2591 cmd_blk = &cs->mcmd_blk; in DAC960_GEM_intr_handler()
2593 scmd = scsi_host_find_tag(cs->host, id - 3); in DAC960_GEM_intr_handler()
2602 dev_err(&cs->pdev->dev, in DAC960_GEM_intr_handler()
2606 if (++next_stat_mbox > cs->last_stat_mbox) in DAC960_GEM_intr_handler()
2607 next_stat_mbox = cs->first_stat_mbox; in DAC960_GEM_intr_handler()
2611 myrs_handle_cmdblk(cs, cmd_blk); in DAC960_GEM_intr_handler()
2613 myrs_handle_scsi(cs, cmd_blk, scmd); in DAC960_GEM_intr_handler()
2616 cs->next_stat_mbox = next_stat_mbox; in DAC960_GEM_intr_handler()
2617 spin_unlock_irqrestore(&cs->queue_lock, flags); in DAC960_GEM_intr_handler()
2756 struct myrs_hba *cs, void __iomem *base) in DAC960_BA_hw_init() argument
2768 myrs_err_status(cs, status, parm0, parm1)) in DAC960_BA_hw_init()
2778 if (!myrs_enable_mmio_mbox(cs, DAC960_BA_mbox_init)) { in DAC960_BA_hw_init()
2785 cs->write_cmd_mbox = DAC960_BA_write_cmd_mbox; in DAC960_BA_hw_init()
2786 cs->get_cmd_mbox = DAC960_BA_mem_mbox_new_cmd; in DAC960_BA_hw_init()
2787 cs->disable_intr = DAC960_BA_disable_intr; in DAC960_BA_hw_init()
2788 cs->reset = DAC960_BA_reset_ctrl; in DAC960_BA_hw_init()
2794 struct myrs_hba *cs = arg; in DAC960_BA_intr_handler() local
2795 void __iomem *base = cs->io_base; in DAC960_BA_intr_handler()
2799 spin_lock_irqsave(&cs->queue_lock, flags); in DAC960_BA_intr_handler()
2801 next_stat_mbox = cs->next_stat_mbox; in DAC960_BA_intr_handler()
2808 cmd_blk = &cs->dcmd_blk; in DAC960_BA_intr_handler()
2810 cmd_blk = &cs->mcmd_blk; in DAC960_BA_intr_handler()
2812 scmd = scsi_host_find_tag(cs->host, id - 3); in DAC960_BA_intr_handler()
2821 dev_err(&cs->pdev->dev, in DAC960_BA_intr_handler()
2825 if (++next_stat_mbox > cs->last_stat_mbox) in DAC960_BA_intr_handler()
2826 next_stat_mbox = cs->first_stat_mbox; in DAC960_BA_intr_handler()
2830 myrs_handle_cmdblk(cs, cmd_blk); in DAC960_BA_intr_handler()
2832 myrs_handle_scsi(cs, cmd_blk, scmd); in DAC960_BA_intr_handler()
2835 cs->next_stat_mbox = next_stat_mbox; in DAC960_BA_intr_handler()
2836 spin_unlock_irqrestore(&cs->queue_lock, flags); in DAC960_BA_intr_handler()
2974 struct myrs_hba *cs, void __iomem *base) in DAC960_LP_hw_init() argument
2986 myrs_err_status(cs, status, parm0, parm1)) in DAC960_LP_hw_init()
2996 if (!myrs_enable_mmio_mbox(cs, DAC960_LP_mbox_init)) { in DAC960_LP_hw_init()
3003 cs->write_cmd_mbox = DAC960_LP_write_cmd_mbox; in DAC960_LP_hw_init()
3004 cs->get_cmd_mbox = DAC960_LP_mem_mbox_new_cmd; in DAC960_LP_hw_init()
3005 cs->disable_intr = DAC960_LP_disable_intr; in DAC960_LP_hw_init()
3006 cs->reset = DAC960_LP_reset_ctrl; in DAC960_LP_hw_init()
3013 struct myrs_hba *cs = arg; in DAC960_LP_intr_handler() local
3014 void __iomem *base = cs->io_base; in DAC960_LP_intr_handler()
3018 spin_lock_irqsave(&cs->queue_lock, flags); in DAC960_LP_intr_handler()
3020 next_stat_mbox = cs->next_stat_mbox; in DAC960_LP_intr_handler()
3027 cmd_blk = &cs->dcmd_blk; in DAC960_LP_intr_handler()
3029 cmd_blk = &cs->mcmd_blk; in DAC960_LP_intr_handler()
3031 scmd = scsi_host_find_tag(cs->host, id - 3); in DAC960_LP_intr_handler()
3040 dev_err(&cs->pdev->dev, in DAC960_LP_intr_handler()
3044 if (++next_stat_mbox > cs->last_stat_mbox) in DAC960_LP_intr_handler()
3045 next_stat_mbox = cs->first_stat_mbox; in DAC960_LP_intr_handler()
3049 myrs_handle_cmdblk(cs, cmd_blk); in DAC960_LP_intr_handler()
3051 myrs_handle_scsi(cs, cmd_blk, scmd); in DAC960_LP_intr_handler()
3054 cs->next_stat_mbox = next_stat_mbox; in DAC960_LP_intr_handler()
3055 spin_unlock_irqrestore(&cs->queue_lock, flags); in DAC960_LP_intr_handler()
3071 struct myrs_hba *cs; in myrs_probe() local
3074 cs = myrs_detect(dev, entry); in myrs_probe()
3075 if (!cs) in myrs_probe()
3078 ret = myrs_get_config(cs); in myrs_probe()
3080 myrs_cleanup(cs); in myrs_probe()
3084 if (!myrs_create_mempools(dev, cs)) { in myrs_probe()
3089 ret = scsi_add_host(cs->host, &dev->dev); in myrs_probe()
3092 myrs_destroy_mempools(cs); in myrs_probe()
3095 scsi_scan_host(cs->host); in myrs_probe()
3098 myrs_cleanup(cs); in myrs_probe()
3105 struct myrs_hba *cs = pci_get_drvdata(pdev); in myrs_remove() local
3107 if (cs == NULL) in myrs_remove()
3110 shost_printk(KERN_NOTICE, cs->host, "Flushing Cache..."); in myrs_remove()
3111 myrs_flush_cache(cs); in myrs_remove()
3112 myrs_destroy_mempools(cs); in myrs_remove()
3113 myrs_cleanup(cs); in myrs_remove()