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()
146 static void myrs_report_progress(struct myrs_hba *cs, unsigned short ldev_num, in myrs_report_progress() argument
150 shost_printk(KERN_INFO, cs->host, in myrs_report_progress()
159 static unsigned char myrs_get_ctlr_info(struct myrs_hba *cs) in myrs_get_ctlr_info() argument
161 struct myrs_cmdblk *cmd_blk = &cs->dcmd_blk; in myrs_get_ctlr_info()
168 ldev_present = cs->ctlr_info->ldev_present; in myrs_get_ctlr_info()
169 ldev_critical = cs->ctlr_info->ldev_critical; in myrs_get_ctlr_info()
170 ldev_offline = cs->ctlr_info->ldev_offline; in myrs_get_ctlr_info()
172 ctlr_info_addr = dma_map_single(&cs->pdev->dev, cs->ctlr_info, in myrs_get_ctlr_info()
175 if (dma_mapping_error(&cs->pdev->dev, ctlr_info_addr)) in myrs_get_ctlr_info()
178 mutex_lock(&cs->dcmd_mutex); in myrs_get_ctlr_info()
190 dev_dbg(&cs->host->shost_gendev, "Sending GetControllerInfo\n"); in myrs_get_ctlr_info()
191 myrs_exec_cmd(cs, cmd_blk); in myrs_get_ctlr_info()
193 mutex_unlock(&cs->dcmd_mutex); in myrs_get_ctlr_info()
194 dma_unmap_single(&cs->pdev->dev, ctlr_info_addr, in myrs_get_ctlr_info()
197 if (cs->ctlr_info->bg_init_active + in myrs_get_ctlr_info()
198 cs->ctlr_info->ldev_init_active + in myrs_get_ctlr_info()
199 cs->ctlr_info->pdev_init_active + in myrs_get_ctlr_info()
200 cs->ctlr_info->cc_active + in myrs_get_ctlr_info()
201 cs->ctlr_info->rbld_active + in myrs_get_ctlr_info()
202 cs->ctlr_info->exp_active != 0) in myrs_get_ctlr_info()
203 cs->needs_update = true; in myrs_get_ctlr_info()
204 if (cs->ctlr_info->ldev_present != ldev_present || in myrs_get_ctlr_info()
205 cs->ctlr_info->ldev_critical != ldev_critical || in myrs_get_ctlr_info()
206 cs->ctlr_info->ldev_offline != ldev_offline) in myrs_get_ctlr_info()
207 shost_printk(KERN_INFO, cs->host, in myrs_get_ctlr_info()
209 cs->ctlr_info->ldev_critical, in myrs_get_ctlr_info()
210 cs->ctlr_info->ldev_offline, in myrs_get_ctlr_info()
211 cs->ctlr_info->ldev_present); in myrs_get_ctlr_info()
220 static unsigned char myrs_get_ldev_info(struct myrs_hba *cs, in myrs_get_ldev_info() argument
223 struct myrs_cmdblk *cmd_blk = &cs->dcmd_blk; in myrs_get_ldev_info()
231 ldev_info_addr = dma_map_single(&cs->pdev->dev, ldev_info, in myrs_get_ldev_info()
234 if (dma_mapping_error(&cs->pdev->dev, ldev_info_addr)) in myrs_get_ldev_info()
237 mutex_lock(&cs->dcmd_mutex); in myrs_get_ldev_info()
249 dev_dbg(&cs->host->shost_gendev, in myrs_get_ldev_info()
251 myrs_exec_cmd(cs, cmd_blk); in myrs_get_ldev_info()
253 mutex_unlock(&cs->dcmd_mutex); in myrs_get_ldev_info()
254 dma_unmap_single(&cs->pdev->dev, ldev_info_addr, in myrs_get_ldev_info()
266 shost_printk(KERN_INFO, cs->host, in myrs_get_ldev_info()
273 shost_printk(KERN_INFO, cs->host, in myrs_get_ldev_info()
279 myrs_report_progress(cs, ldev_num, in myrs_get_ldev_info()
283 myrs_report_progress(cs, ldev_num, in myrs_get_ldev_info()
287 myrs_report_progress(cs, ldev_num, in myrs_get_ldev_info()
291 myrs_report_progress(cs, ldev_num, in myrs_get_ldev_info()
295 shost_printk(KERN_INFO, cs->host, in myrs_get_ldev_info()
307 static unsigned char myrs_get_pdev_info(struct myrs_hba *cs, in myrs_get_pdev_info() argument
311 struct myrs_cmdblk *cmd_blk = &cs->dcmd_blk; in myrs_get_pdev_info()
317 pdev_info_addr = dma_map_single(&cs->pdev->dev, pdev_info, in myrs_get_pdev_info()
320 if (dma_mapping_error(&cs->pdev->dev, pdev_info_addr)) in myrs_get_pdev_info()
323 mutex_lock(&cs->dcmd_mutex); in myrs_get_pdev_info()
337 dev_dbg(&cs->host->shost_gendev, in myrs_get_pdev_info()
340 myrs_exec_cmd(cs, cmd_blk); in myrs_get_pdev_info()
342 mutex_unlock(&cs->dcmd_mutex); in myrs_get_pdev_info()
343 dma_unmap_single(&cs->pdev->dev, pdev_info_addr, in myrs_get_pdev_info()
351 static unsigned char myrs_dev_op(struct myrs_hba *cs, in myrs_dev_op() argument
354 struct myrs_cmdblk *cmd_blk = &cs->dcmd_blk; in myrs_dev_op()
358 mutex_lock(&cs->dcmd_mutex); in myrs_dev_op()
366 myrs_exec_cmd(cs, cmd_blk); in myrs_dev_op()
368 mutex_unlock(&cs->dcmd_mutex); in myrs_dev_op()
376 static unsigned char myrs_translate_pdev(struct myrs_hba *cs, in myrs_translate_pdev() argument
380 struct pci_dev *pdev = cs->pdev; in myrs_translate_pdev()
394 mutex_lock(&cs->dcmd_mutex); in myrs_translate_pdev()
395 cmd_blk = &cs->dcmd_blk; in myrs_translate_pdev()
409 myrs_exec_cmd(cs, cmd_blk); in myrs_translate_pdev()
411 mutex_unlock(&cs->dcmd_mutex); in myrs_translate_pdev()
420 static unsigned char myrs_get_event(struct myrs_hba *cs, in myrs_get_event() argument
423 struct pci_dev *pdev = cs->pdev; in myrs_get_event()
425 struct myrs_cmdblk *cmd_blk = &cs->mcmd_blk; in myrs_get_event()
444 myrs_exec_cmd(cs, cmd_blk); in myrs_get_event()
455 static unsigned char myrs_get_fwstatus(struct myrs_hba *cs) in myrs_get_fwstatus() argument
457 struct myrs_cmdblk *cmd_blk = &cs->mcmd_blk; in myrs_get_fwstatus()
470 sgl->sge[0].sge_addr = cs->fwstat_addr; in myrs_get_fwstatus()
472 dev_dbg(&cs->host->shost_gendev, "Sending GetHealthStatus\n"); in myrs_get_fwstatus()
473 myrs_exec_cmd(cs, cmd_blk); in myrs_get_fwstatus()
482 static bool myrs_enable_mmio_mbox(struct myrs_hba *cs, in myrs_enable_mmio_mbox() argument
485 void __iomem *base = cs->io_base; in myrs_enable_mmio_mbox()
486 struct pci_dev *pdev = cs->pdev; in myrs_enable_mmio_mbox()
506 cs->cmd_mbox_size = MYRS_MAX_CMD_MBOX * sizeof(union myrs_cmd_mbox); in myrs_enable_mmio_mbox()
507 cmd_mbox = dma_alloc_coherent(&pdev->dev, cs->cmd_mbox_size, in myrs_enable_mmio_mbox()
508 &cs->cmd_mbox_addr, GFP_KERNEL); in myrs_enable_mmio_mbox()
509 if (dma_mapping_error(&pdev->dev, cs->cmd_mbox_addr)) { in myrs_enable_mmio_mbox()
513 cs->first_cmd_mbox = cmd_mbox; in myrs_enable_mmio_mbox()
515 cs->last_cmd_mbox = cmd_mbox; in myrs_enable_mmio_mbox()
516 cs->next_cmd_mbox = cs->first_cmd_mbox; in myrs_enable_mmio_mbox()
517 cs->prev_cmd_mbox1 = cs->last_cmd_mbox; in myrs_enable_mmio_mbox()
518 cs->prev_cmd_mbox2 = cs->last_cmd_mbox - 1; in myrs_enable_mmio_mbox()
521 cs->stat_mbox_size = MYRS_MAX_STAT_MBOX * sizeof(struct myrs_stat_mbox); in myrs_enable_mmio_mbox()
522 stat_mbox = dma_alloc_coherent(&pdev->dev, cs->stat_mbox_size, in myrs_enable_mmio_mbox()
523 &cs->stat_mbox_addr, GFP_KERNEL); in myrs_enable_mmio_mbox()
524 if (dma_mapping_error(&pdev->dev, cs->stat_mbox_addr)) { in myrs_enable_mmio_mbox()
529 cs->first_stat_mbox = stat_mbox; in myrs_enable_mmio_mbox()
531 cs->last_stat_mbox = stat_mbox; in myrs_enable_mmio_mbox()
532 cs->next_stat_mbox = cs->first_stat_mbox; in myrs_enable_mmio_mbox()
534 cs->fwstat_buf = dma_alloc_coherent(&pdev->dev, in myrs_enable_mmio_mbox()
536 &cs->fwstat_addr, GFP_KERNEL); in myrs_enable_mmio_mbox()
537 if (dma_mapping_error(&pdev->dev, cs->fwstat_addr)) { in myrs_enable_mmio_mbox()
539 cs->fwstat_buf = NULL; in myrs_enable_mmio_mbox()
542 cs->ctlr_info = kzalloc(sizeof(struct myrs_ctlr_info), in myrs_enable_mmio_mbox()
544 if (!cs->ctlr_info) in myrs_enable_mmio_mbox()
547 cs->event_buf = kzalloc(sizeof(struct myrs_event), in myrs_enable_mmio_mbox()
549 if (!cs->event_buf) in myrs_enable_mmio_mbox()
566 mbox->set_mbox.fwstat_buf_addr = cs->fwstat_addr; in myrs_enable_mmio_mbox()
567 mbox->set_mbox.first_cmd_mbox_addr = cs->cmd_mbox_addr; in myrs_enable_mmio_mbox()
568 mbox->set_mbox.first_stat_mbox_addr = cs->stat_mbox_addr; in myrs_enable_mmio_mbox()
583 static int myrs_get_config(struct myrs_hba *cs) in myrs_get_config() argument
585 struct myrs_ctlr_info *info = cs->ctlr_info; in myrs_get_config()
586 struct Scsi_Host *shost = cs->host; in myrs_get_config()
593 mutex_lock(&cs->cinfo_mutex); in myrs_get_config()
594 status = myrs_get_ctlr_info(cs); in myrs_get_config()
595 mutex_unlock(&cs->cinfo_mutex); in myrs_get_config()
611 strcpy(cs->model_name, "DAC960 "); in myrs_get_config()
612 strcat(cs->model_name, model); in myrs_get_config()
814 static void myrs_log_event(struct myrs_hba *cs, struct myrs_event *ev) in myrs_log_event() argument
819 struct Scsi_Host *shost = cs->host; in myrs_log_event()
859 sdev->channel < cs->ctlr_info->physchan_present) { in myrs_log_event()
886 cs->needs_update = true; in myrs_log_event()
892 cs->needs_update = true; in myrs_log_event()
916 if (cs->disable_enc_msg) in myrs_log_event()
941 struct myrs_hba *cs = shost_priv(sdev->host); in raid_state_show() local
947 if (sdev->channel >= cs->ctlr_info->physchan_present) { in raid_state_show()
976 struct myrs_hba *cs = shost_priv(sdev->host); in raid_state_store() local
993 if (sdev->channel < cs->ctlr_info->physchan_present) { in raid_state_store()
1004 status = myrs_translate_pdev(cs, sdev->channel, sdev->id, in raid_state_store()
1020 mutex_lock(&cs->dcmd_mutex); in raid_state_store()
1021 cmd_blk = &cs->dcmd_blk; in raid_state_store()
1031 myrs_exec_cmd(cs, cmd_blk); in raid_state_store()
1033 mutex_unlock(&cs->dcmd_mutex); in raid_state_store()
1035 if (sdev->channel < cs->ctlr_info->physchan_present) { in raid_state_store()
1060 struct myrs_hba *cs = shost_priv(sdev->host); in raid_level_show() local
1066 if (sdev->channel >= cs->ctlr_info->physchan_present) { in raid_level_show()
1086 struct myrs_hba *cs = shost_priv(sdev->host); in rebuild_show() local
1091 if (sdev->channel < cs->ctlr_info->physchan_present) in rebuild_show()
1096 status = myrs_get_ldev_info(cs, ldev_num, ldev_info); in rebuild_show()
1115 struct myrs_hba *cs = shost_priv(sdev->host); in rebuild_store() local
1123 if (sdev->channel < cs->ctlr_info->physchan_present) in rebuild_store()
1135 status = myrs_get_ldev_info(cs, ldev_num, ldev_info); in rebuild_store()
1154 mutex_lock(&cs->dcmd_mutex); in rebuild_store()
1155 cmd_blk = &cs->dcmd_blk; in rebuild_store()
1169 myrs_exec_cmd(cs, cmd_blk); in rebuild_store()
1171 mutex_unlock(&cs->dcmd_mutex); in rebuild_store()
1191 struct myrs_hba *cs = shost_priv(sdev->host); in consistency_check_show() local
1196 if (sdev->channel < cs->ctlr_info->physchan_present) in consistency_check_show()
1203 status = myrs_get_ldev_info(cs, ldev_num, ldev_info); in consistency_check_show()
1216 struct myrs_hba *cs = shost_priv(sdev->host); in consistency_check_store() local
1224 if (sdev->channel < cs->ctlr_info->physchan_present) in consistency_check_store()
1236 status = myrs_get_ldev_info(cs, ldev_num, ldev_info); in consistency_check_store()
1256 mutex_lock(&cs->dcmd_mutex); in consistency_check_store()
1257 cmd_blk = &cs->dcmd_blk; in consistency_check_store()
1273 myrs_exec_cmd(cs, cmd_blk); in consistency_check_store()
1275 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()
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
1587 struct myrs_hba *cs = shost_priv(shost); in myrs_queuecommand() local
1611 if (scmd->device->channel >= cs->ctlr_info->physchan_present) { in myrs_queuecommand()
1622 myrs_mode_sense(cs, scmd, ldev_info); in myrs_queuecommand()
1632 cmd_blk->sense = dma_pool_alloc(cs->sense_pool, GFP_ATOMIC, in myrs_queuecommand()
1640 if (scmd->device->channel >= cs->ctlr_info->physchan_present) { in myrs_queuecommand()
1676 cmd_blk->dcdb = dma_pool_alloc(cs->dcdb_pool, GFP_ATOMIC, in myrs_queuecommand()
1679 dma_pool_free(cs->sense_pool, cmd_blk->sense, in myrs_queuecommand()
1686 if (scmd->device->channel >= cs->ctlr_info->physchan_present) { in myrs_queuecommand()
1733 hw_sgl = dma_pool_alloc(cs->sg_pool, GFP_ATOMIC, in myrs_queuecommand()
1737 dma_pool_free(cs->dcdb_pool, in myrs_queuecommand()
1743 dma_pool_free(cs->sense_pool, in myrs_queuecommand()
1774 spin_lock_irqsave(&cs->queue_lock, flags); in myrs_queuecommand()
1775 myrs_qcmd(cs, cmd_blk); in myrs_queuecommand()
1776 spin_unlock_irqrestore(&cs->queue_lock, flags); in myrs_queuecommand()
1781 static unsigned short myrs_translate_ldev(struct myrs_hba *cs, in myrs_translate_ldev() argument
1786 sdev->channel - cs->ctlr_info->physchan_present; in myrs_translate_ldev()
1795 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_slave_alloc() local
1801 if (sdev->channel >= cs->ctlr_info->physchan_present) { in myrs_slave_alloc()
1808 ldev_num = myrs_translate_ldev(cs, sdev); in myrs_slave_alloc()
1814 status = myrs_get_ldev_info(cs, ldev_num, ldev_info); in myrs_slave_alloc()
1876 status = myrs_get_pdev_info(cs, sdev->channel, in myrs_slave_alloc()
1891 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_slave_configure() local
1897 if (sdev->channel < cs->ctlr_info->physchan_present) { in myrs_slave_configure()
1941 struct myrs_hba *cs; in myrs_alloc_host() local
1949 cs = shost_priv(shost); in myrs_alloc_host()
1950 mutex_init(&cs->dcmd_mutex); in myrs_alloc_host()
1951 mutex_init(&cs->cinfo_mutex); in myrs_alloc_host()
1952 cs->host = shost; in myrs_alloc_host()
1954 return cs; in myrs_alloc_host()
1969 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_is_raid() local
1971 return (sdev->channel >= cs->ctlr_info->physchan_present) ? 1 : 0; in myrs_is_raid()
1982 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_get_resync() local
1987 if (sdev->channel < cs->ctlr_info->physchan_present || !ldev_info) in myrs_get_resync()
1992 status = myrs_get_ldev_info(cs, ldev_num, ldev_info); in myrs_get_resync()
2007 struct myrs_hba *cs = shost_priv(sdev->host); in myrs_get_state() local
2011 if (sdev->channel < cs->ctlr_info->physchan_present || !ldev_info) in myrs_get_state()
2046 static void myrs_flush_cache(struct myrs_hba *cs) in myrs_flush_cache() argument
2048 myrs_dev_op(cs, MYRS_IOCTL_FLUSH_DEVICE_DATA, MYRS_RAID_CONTROLLER); in myrs_flush_cache()
2051 static void myrs_handle_scsi(struct myrs_hba *cs, struct myrs_cmdblk *cmd_blk, in myrs_handle_scsi() argument
2069 dma_pool_free(cs->sense_pool, cmd_blk->sense, in myrs_handle_scsi()
2075 dma_pool_free(cs->dcdb_pool, cmd_blk->dcdb, in myrs_handle_scsi()
2081 dma_pool_free(cs->sg_pool, cmd_blk->sgl, in myrs_handle_scsi()
2096 static void myrs_handle_cmdblk(struct myrs_hba *cs, struct myrs_cmdblk *cmd_blk) in myrs_handle_cmdblk() argument
2109 struct myrs_hba *cs = container_of(work, struct myrs_hba, in myrs_monitor() local
2111 struct Scsi_Host *shost = cs->host; in myrs_monitor()
2112 struct myrs_ctlr_info *info = cs->ctlr_info; in myrs_monitor()
2113 unsigned int epoch = cs->fwstat_buf->epoch; in myrs_monitor()
2119 status = myrs_get_fwstatus(cs); in myrs_monitor()
2121 if (cs->needs_update) { in myrs_monitor()
2122 cs->needs_update = false; in myrs_monitor()
2123 mutex_lock(&cs->cinfo_mutex); in myrs_monitor()
2124 status = myrs_get_ctlr_info(cs); in myrs_monitor()
2125 mutex_unlock(&cs->cinfo_mutex); in myrs_monitor()
2127 if (cs->fwstat_buf->next_evseq - cs->next_evseq > 0) { in myrs_monitor()
2128 status = myrs_get_event(cs, cs->next_evseq, in myrs_monitor()
2129 cs->event_buf); in myrs_monitor()
2131 myrs_log_event(cs, cs->event_buf); in myrs_monitor()
2132 cs->next_evseq++; in myrs_monitor()
2137 if (time_after(jiffies, cs->secondary_monitor_time in myrs_monitor()
2139 cs->secondary_monitor_time = jiffies; in myrs_monitor()
2159 myrs_get_ldev_info(cs, ldev_num, ldev_info); in myrs_monitor()
2161 cs->needs_update = true; in myrs_monitor()
2163 if (epoch == cs->epoch && in myrs_monitor()
2164 cs->fwstat_buf->next_evseq == cs->next_evseq && in myrs_monitor()
2165 (cs->needs_update == false || in myrs_monitor()
2166 time_before(jiffies, cs->primary_monitor_time in myrs_monitor()
2172 cs->primary_monitor_time = jiffies; in myrs_monitor()
2173 queue_delayed_work(cs->work_q, &cs->monitor_work, interval); in myrs_monitor()
2176 static bool myrs_create_mempools(struct pci_dev *pdev, struct myrs_hba *cs) in myrs_create_mempools() argument
2178 struct Scsi_Host *shost = cs->host; in myrs_create_mempools()
2183 cs->sg_pool = dma_pool_create("myrs_sg", &pdev->dev, in myrs_create_mempools()
2185 if (cs->sg_pool == NULL) { in myrs_create_mempools()
2191 cs->sense_pool = dma_pool_create("myrs_sense", &pdev->dev, in myrs_create_mempools()
2193 if (cs->sense_pool == NULL) { in myrs_create_mempools()
2194 dma_pool_destroy(cs->sg_pool); in myrs_create_mempools()
2195 cs->sg_pool = NULL; in myrs_create_mempools()
2201 cs->dcdb_pool = dma_pool_create("myrs_dcdb", &pdev->dev, in myrs_create_mempools()
2204 if (!cs->dcdb_pool) { in myrs_create_mempools()
2205 dma_pool_destroy(cs->sg_pool); in myrs_create_mempools()
2206 cs->sg_pool = NULL; in myrs_create_mempools()
2207 dma_pool_destroy(cs->sense_pool); in myrs_create_mempools()
2208 cs->sense_pool = NULL; in myrs_create_mempools()
2214 snprintf(cs->work_q_name, sizeof(cs->work_q_name), in myrs_create_mempools()
2216 cs->work_q = create_singlethread_workqueue(cs->work_q_name); in myrs_create_mempools()
2217 if (!cs->work_q) { in myrs_create_mempools()
2218 dma_pool_destroy(cs->dcdb_pool); in myrs_create_mempools()
2219 cs->dcdb_pool = NULL; in myrs_create_mempools()
2220 dma_pool_destroy(cs->sg_pool); in myrs_create_mempools()
2221 cs->sg_pool = NULL; in myrs_create_mempools()
2222 dma_pool_destroy(cs->sense_pool); in myrs_create_mempools()
2223 cs->sense_pool = NULL; in myrs_create_mempools()
2230 INIT_DELAYED_WORK(&cs->monitor_work, myrs_monitor); in myrs_create_mempools()
2231 queue_delayed_work(cs->work_q, &cs->monitor_work, 1); in myrs_create_mempools()
2236 static void myrs_destroy_mempools(struct myrs_hba *cs) in myrs_destroy_mempools() argument
2238 cancel_delayed_work_sync(&cs->monitor_work); in myrs_destroy_mempools()
2239 destroy_workqueue(cs->work_q); in myrs_destroy_mempools()
2241 dma_pool_destroy(cs->sg_pool); in myrs_destroy_mempools()
2242 dma_pool_destroy(cs->dcdb_pool); in myrs_destroy_mempools()
2243 dma_pool_destroy(cs->sense_pool); in myrs_destroy_mempools()
2246 static void myrs_unmap(struct myrs_hba *cs) in myrs_unmap() argument
2248 kfree(cs->event_buf); in myrs_unmap()
2249 kfree(cs->ctlr_info); in myrs_unmap()
2250 if (cs->fwstat_buf) { in myrs_unmap()
2251 dma_free_coherent(&cs->pdev->dev, sizeof(struct myrs_fwstat), in myrs_unmap()
2252 cs->fwstat_buf, cs->fwstat_addr); in myrs_unmap()
2253 cs->fwstat_buf = NULL; in myrs_unmap()
2255 if (cs->first_stat_mbox) { in myrs_unmap()
2256 dma_free_coherent(&cs->pdev->dev, cs->stat_mbox_size, in myrs_unmap()
2257 cs->first_stat_mbox, cs->stat_mbox_addr); in myrs_unmap()
2258 cs->first_stat_mbox = NULL; in myrs_unmap()
2260 if (cs->first_cmd_mbox) { in myrs_unmap()
2261 dma_free_coherent(&cs->pdev->dev, cs->cmd_mbox_size, in myrs_unmap()
2262 cs->first_cmd_mbox, cs->cmd_mbox_addr); in myrs_unmap()
2263 cs->first_cmd_mbox = NULL; in myrs_unmap()
2267 static void myrs_cleanup(struct myrs_hba *cs) in myrs_cleanup() argument
2269 struct pci_dev *pdev = cs->pdev; in myrs_cleanup()
2272 myrs_unmap(cs); in myrs_cleanup()
2274 if (cs->mmio_base) { in myrs_cleanup()
2275 if (cs->disable_intr) in myrs_cleanup()
2276 cs->disable_intr(cs); in myrs_cleanup()
2277 iounmap(cs->mmio_base); in myrs_cleanup()
2278 cs->mmio_base = NULL; in myrs_cleanup()
2280 if (cs->irq) in myrs_cleanup()
2281 free_irq(cs->irq, cs); in myrs_cleanup()
2282 if (cs->io_addr) in myrs_cleanup()
2283 release_region(cs->io_addr, 0x80); in myrs_cleanup()
2286 scsi_host_put(cs->host); in myrs_cleanup()
2296 struct myrs_hba *cs = NULL; in myrs_detect() local
2298 cs = myrs_alloc_host(pdev, entry); in myrs_detect()
2299 if (!cs) { in myrs_detect()
2303 cs->pdev = pdev; in myrs_detect()
2308 cs->pci_addr = pci_resource_start(pdev, 0); in myrs_detect()
2310 pci_set_drvdata(pdev, cs); in myrs_detect()
2311 spin_lock_init(&cs->queue_lock); in myrs_detect()
2315 cs->mmio_base = ioremap(cs->pci_addr & PAGE_MASK, mmio_size); in myrs_detect()
2316 if (cs->mmio_base == NULL) { in myrs_detect()
2322 cs->io_base = cs->mmio_base + (cs->pci_addr & ~PAGE_MASK); in myrs_detect()
2323 if (privdata->hw_init(pdev, cs, cs->io_base)) in myrs_detect()
2327 if (request_irq(pdev->irq, irq_handler, IRQF_SHARED, "myrs", cs) < 0) { in myrs_detect()
2332 cs->irq = pdev->irq; in myrs_detect()
2333 return cs; in myrs_detect()
2338 myrs_cleanup(cs); in myrs_detect()
2348 static bool myrs_err_status(struct myrs_hba *cs, unsigned char status, in myrs_err_status() argument
2351 struct pci_dev *pdev = cs->pdev; in myrs_err_status()
2579 struct myrs_hba *cs, void __iomem *base) in DAC960_GEM_hw_init() argument
2591 myrs_err_status(cs, status, parm0, parm1)) in DAC960_GEM_hw_init()
2601 if (!myrs_enable_mmio_mbox(cs, DAC960_GEM_mbox_init)) { in DAC960_GEM_hw_init()
2608 cs->write_cmd_mbox = DAC960_GEM_write_cmd_mbox; in DAC960_GEM_hw_init()
2609 cs->get_cmd_mbox = DAC960_GEM_mem_mbox_new_cmd; in DAC960_GEM_hw_init()
2610 cs->disable_intr = DAC960_GEM_disable_intr; in DAC960_GEM_hw_init()
2611 cs->reset = DAC960_GEM_reset_ctrl; in DAC960_GEM_hw_init()
2617 struct myrs_hba *cs = arg; in DAC960_GEM_intr_handler() local
2618 void __iomem *base = cs->io_base; in DAC960_GEM_intr_handler()
2622 spin_lock_irqsave(&cs->queue_lock, flags); in DAC960_GEM_intr_handler()
2624 next_stat_mbox = cs->next_stat_mbox; in DAC960_GEM_intr_handler()
2631 cmd_blk = &cs->dcmd_blk; in DAC960_GEM_intr_handler()
2633 cmd_blk = &cs->mcmd_blk; in DAC960_GEM_intr_handler()
2635 scmd = scsi_host_find_tag(cs->host, id - 3); in DAC960_GEM_intr_handler()
2644 dev_err(&cs->pdev->dev, in DAC960_GEM_intr_handler()
2648 if (++next_stat_mbox > cs->last_stat_mbox) in DAC960_GEM_intr_handler()
2649 next_stat_mbox = cs->first_stat_mbox; in DAC960_GEM_intr_handler()
2653 myrs_handle_cmdblk(cs, cmd_blk); in DAC960_GEM_intr_handler()
2655 myrs_handle_scsi(cs, cmd_blk, scmd); in DAC960_GEM_intr_handler()
2658 cs->next_stat_mbox = next_stat_mbox; in DAC960_GEM_intr_handler()
2659 spin_unlock_irqrestore(&cs->queue_lock, flags); in DAC960_GEM_intr_handler()
2829 struct myrs_hba *cs, void __iomem *base) in DAC960_BA_hw_init() argument
2841 myrs_err_status(cs, status, parm0, parm1)) in DAC960_BA_hw_init()
2851 if (!myrs_enable_mmio_mbox(cs, DAC960_BA_mbox_init)) { in DAC960_BA_hw_init()
2858 cs->write_cmd_mbox = DAC960_BA_write_cmd_mbox; in DAC960_BA_hw_init()
2859 cs->get_cmd_mbox = DAC960_BA_mem_mbox_new_cmd; in DAC960_BA_hw_init()
2860 cs->disable_intr = DAC960_BA_disable_intr; in DAC960_BA_hw_init()
2861 cs->reset = DAC960_BA_reset_ctrl; in DAC960_BA_hw_init()
2867 struct myrs_hba *cs = arg; in DAC960_BA_intr_handler() local
2868 void __iomem *base = cs->io_base; in DAC960_BA_intr_handler()
2872 spin_lock_irqsave(&cs->queue_lock, flags); in DAC960_BA_intr_handler()
2874 next_stat_mbox = cs->next_stat_mbox; in DAC960_BA_intr_handler()
2881 cmd_blk = &cs->dcmd_blk; in DAC960_BA_intr_handler()
2883 cmd_blk = &cs->mcmd_blk; in DAC960_BA_intr_handler()
2885 scmd = scsi_host_find_tag(cs->host, id - 3); in DAC960_BA_intr_handler()
2894 dev_err(&cs->pdev->dev, in DAC960_BA_intr_handler()
2898 if (++next_stat_mbox > cs->last_stat_mbox) in DAC960_BA_intr_handler()
2899 next_stat_mbox = cs->first_stat_mbox; in DAC960_BA_intr_handler()
2903 myrs_handle_cmdblk(cs, cmd_blk); in DAC960_BA_intr_handler()
2905 myrs_handle_scsi(cs, cmd_blk, scmd); in DAC960_BA_intr_handler()
2908 cs->next_stat_mbox = next_stat_mbox; in DAC960_BA_intr_handler()
2909 spin_unlock_irqrestore(&cs->queue_lock, flags); in DAC960_BA_intr_handler()
3078 struct myrs_hba *cs, void __iomem *base) in DAC960_LP_hw_init() argument
3090 myrs_err_status(cs, status, parm0, parm1)) in DAC960_LP_hw_init()
3100 if (!myrs_enable_mmio_mbox(cs, DAC960_LP_mbox_init)) { in DAC960_LP_hw_init()
3107 cs->write_cmd_mbox = DAC960_LP_write_cmd_mbox; in DAC960_LP_hw_init()
3108 cs->get_cmd_mbox = DAC960_LP_mem_mbox_new_cmd; in DAC960_LP_hw_init()
3109 cs->disable_intr = DAC960_LP_disable_intr; in DAC960_LP_hw_init()
3110 cs->reset = DAC960_LP_reset_ctrl; in DAC960_LP_hw_init()
3117 struct myrs_hba *cs = arg; in DAC960_LP_intr_handler() local
3118 void __iomem *base = cs->io_base; in DAC960_LP_intr_handler()
3122 spin_lock_irqsave(&cs->queue_lock, flags); in DAC960_LP_intr_handler()
3124 next_stat_mbox = cs->next_stat_mbox; in DAC960_LP_intr_handler()
3131 cmd_blk = &cs->dcmd_blk; in DAC960_LP_intr_handler()
3133 cmd_blk = &cs->mcmd_blk; in DAC960_LP_intr_handler()
3135 scmd = scsi_host_find_tag(cs->host, id - 3); in DAC960_LP_intr_handler()
3144 dev_err(&cs->pdev->dev, in DAC960_LP_intr_handler()
3148 if (++next_stat_mbox > cs->last_stat_mbox) in DAC960_LP_intr_handler()
3149 next_stat_mbox = cs->first_stat_mbox; in DAC960_LP_intr_handler()
3153 myrs_handle_cmdblk(cs, cmd_blk); in DAC960_LP_intr_handler()
3155 myrs_handle_scsi(cs, cmd_blk, scmd); in DAC960_LP_intr_handler()
3158 cs->next_stat_mbox = next_stat_mbox; in DAC960_LP_intr_handler()
3159 spin_unlock_irqrestore(&cs->queue_lock, flags); in DAC960_LP_intr_handler()
3175 struct myrs_hba *cs; in myrs_probe() local
3178 cs = myrs_detect(dev, entry); in myrs_probe()
3179 if (!cs) in myrs_probe()
3182 ret = myrs_get_config(cs); in myrs_probe()
3184 myrs_cleanup(cs); in myrs_probe()
3188 if (!myrs_create_mempools(dev, cs)) { in myrs_probe()
3193 ret = scsi_add_host(cs->host, &dev->dev); in myrs_probe()
3196 myrs_destroy_mempools(cs); in myrs_probe()
3199 scsi_scan_host(cs->host); in myrs_probe()
3202 myrs_cleanup(cs); in myrs_probe()
3209 struct myrs_hba *cs = pci_get_drvdata(pdev); in myrs_remove() local
3211 if (cs == NULL) in myrs_remove()
3214 shost_printk(KERN_NOTICE, cs->host, "Flushing Cache..."); in myrs_remove()
3215 myrs_flush_cache(cs); in myrs_remove()
3216 myrs_destroy_mempools(cs); in myrs_remove()
3217 myrs_cleanup(cs); in myrs_remove()