Lines Matching refs:shost

74 int scsi_host_set_state(struct Scsi_Host *shost, enum scsi_host_state state)  in scsi_host_set_state()  argument
76 enum scsi_host_state oldstate = shost->shost_state; in scsi_host_set_state()
147 shost->shost_state = state; in scsi_host_set_state()
152 shost_printk(KERN_ERR, shost, in scsi_host_set_state()
164 void scsi_remove_host(struct Scsi_Host *shost) in scsi_remove_host() argument
168 mutex_lock(&shost->scan_mutex); in scsi_remove_host()
169 spin_lock_irqsave(shost->host_lock, flags); in scsi_remove_host()
170 if (scsi_host_set_state(shost, SHOST_CANCEL)) in scsi_remove_host()
171 if (scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY)) { in scsi_remove_host()
172 spin_unlock_irqrestore(shost->host_lock, flags); in scsi_remove_host()
173 mutex_unlock(&shost->scan_mutex); in scsi_remove_host()
176 spin_unlock_irqrestore(shost->host_lock, flags); in scsi_remove_host()
178 scsi_autopm_get_host(shost); in scsi_remove_host()
179 flush_workqueue(shost->tmf_work_q); in scsi_remove_host()
180 scsi_forget_host(shost); in scsi_remove_host()
181 mutex_unlock(&shost->scan_mutex); in scsi_remove_host()
182 scsi_proc_host_rm(shost); in scsi_remove_host()
184 spin_lock_irqsave(shost->host_lock, flags); in scsi_remove_host()
185 if (scsi_host_set_state(shost, SHOST_DEL)) in scsi_remove_host()
186 BUG_ON(scsi_host_set_state(shost, SHOST_DEL_RECOVERY)); in scsi_remove_host()
187 spin_unlock_irqrestore(shost->host_lock, flags); in scsi_remove_host()
189 transport_unregister_device(&shost->shost_gendev); in scsi_remove_host()
190 device_unregister(&shost->shost_dev); in scsi_remove_host()
191 device_del(&shost->shost_gendev); in scsi_remove_host()
208 int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, in scsi_add_host_with_dma() argument
211 struct scsi_host_template *sht = shost->hostt; in scsi_add_host_with_dma()
214 shost_printk(KERN_INFO, shost, "%s\n", in scsi_add_host_with_dma()
215 sht->info ? sht->info(shost) : sht->name); in scsi_add_host_with_dma()
217 if (!shost->can_queue) { in scsi_add_host_with_dma()
218 shost_printk(KERN_ERR, shost, in scsi_add_host_with_dma()
223 error = scsi_init_sense_cache(shost); in scsi_add_host_with_dma()
227 error = scsi_mq_setup_tags(shost); in scsi_add_host_with_dma()
231 if (!shost->shost_gendev.parent) in scsi_add_host_with_dma()
232 shost->shost_gendev.parent = dev ? dev : &platform_bus; in scsi_add_host_with_dma()
234 dma_dev = shost->shost_gendev.parent; in scsi_add_host_with_dma()
236 shost->dma_dev = dma_dev; in scsi_add_host_with_dma()
243 pm_runtime_get_noresume(&shost->shost_gendev); in scsi_add_host_with_dma()
244 pm_runtime_set_active(&shost->shost_gendev); in scsi_add_host_with_dma()
245 pm_runtime_enable(&shost->shost_gendev); in scsi_add_host_with_dma()
246 device_enable_async_suspend(&shost->shost_gendev); in scsi_add_host_with_dma()
248 error = device_add(&shost->shost_gendev); in scsi_add_host_with_dma()
252 scsi_host_set_state(shost, SHOST_RUNNING); in scsi_add_host_with_dma()
253 get_device(shost->shost_gendev.parent); in scsi_add_host_with_dma()
255 device_enable_async_suspend(&shost->shost_dev); in scsi_add_host_with_dma()
257 error = device_add(&shost->shost_dev); in scsi_add_host_with_dma()
261 get_device(&shost->shost_gendev); in scsi_add_host_with_dma()
263 if (shost->transportt->host_size) { in scsi_add_host_with_dma()
264 shost->shost_data = kzalloc(shost->transportt->host_size, in scsi_add_host_with_dma()
266 if (shost->shost_data == NULL) { in scsi_add_host_with_dma()
272 if (shost->transportt->create_work_queue) { in scsi_add_host_with_dma()
273 snprintf(shost->work_q_name, sizeof(shost->work_q_name), in scsi_add_host_with_dma()
274 "scsi_wq_%d", shost->host_no); in scsi_add_host_with_dma()
275 shost->work_q = alloc_workqueue("%s", in scsi_add_host_with_dma()
277 1, shost->work_q_name); in scsi_add_host_with_dma()
279 if (!shost->work_q) { in scsi_add_host_with_dma()
285 error = scsi_sysfs_add_host(shost); in scsi_add_host_with_dma()
289 scsi_proc_host_add(shost); in scsi_add_host_with_dma()
290 scsi_autopm_put_host(shost); in scsi_add_host_with_dma()
294 if (shost->work_q) in scsi_add_host_with_dma()
295 destroy_workqueue(shost->work_q); in scsi_add_host_with_dma()
297 kfree(shost->shost_data); in scsi_add_host_with_dma()
299 device_del(&shost->shost_dev); in scsi_add_host_with_dma()
301 device_del(&shost->shost_gendev); in scsi_add_host_with_dma()
303 device_disable_async_suspend(&shost->shost_gendev); in scsi_add_host_with_dma()
304 pm_runtime_disable(&shost->shost_gendev); in scsi_add_host_with_dma()
305 pm_runtime_set_suspended(&shost->shost_gendev); in scsi_add_host_with_dma()
306 pm_runtime_put_noidle(&shost->shost_gendev); in scsi_add_host_with_dma()
307 scsi_mq_destroy_tags(shost); in scsi_add_host_with_dma()
315 struct Scsi_Host *shost = dev_to_shost(dev); in scsi_host_dev_release() local
318 scsi_proc_hostdir_rm(shost->hostt); in scsi_host_dev_release()
323 if (shost->tmf_work_q) in scsi_host_dev_release()
324 destroy_workqueue(shost->tmf_work_q); in scsi_host_dev_release()
325 if (shost->ehandler) in scsi_host_dev_release()
326 kthread_stop(shost->ehandler); in scsi_host_dev_release()
327 if (shost->work_q) in scsi_host_dev_release()
328 destroy_workqueue(shost->work_q); in scsi_host_dev_release()
330 if (shost->shost_state == SHOST_CREATED) { in scsi_host_dev_release()
338 kfree(dev_name(&shost->shost_dev)); in scsi_host_dev_release()
341 if (shost->tag_set.tags) in scsi_host_dev_release()
342 scsi_mq_destroy_tags(shost); in scsi_host_dev_release()
344 kfree(shost->shost_data); in scsi_host_dev_release()
346 ida_simple_remove(&host_index_ida, shost->host_no); in scsi_host_dev_release()
350 kfree(shost); in scsi_host_dev_release()
373 struct Scsi_Host *shost; in scsi_host_alloc() local
380 shost = kzalloc(sizeof(struct Scsi_Host) + privsize, gfp_mask); in scsi_host_alloc()
381 if (!shost) in scsi_host_alloc()
384 shost->host_lock = &shost->default_lock; in scsi_host_alloc()
385 spin_lock_init(shost->host_lock); in scsi_host_alloc()
386 shost->shost_state = SHOST_CREATED; in scsi_host_alloc()
387 INIT_LIST_HEAD(&shost->__devices); in scsi_host_alloc()
388 INIT_LIST_HEAD(&shost->__targets); in scsi_host_alloc()
389 INIT_LIST_HEAD(&shost->eh_cmd_q); in scsi_host_alloc()
390 INIT_LIST_HEAD(&shost->starved_list); in scsi_host_alloc()
391 init_waitqueue_head(&shost->host_wait); in scsi_host_alloc()
392 mutex_init(&shost->scan_mutex); in scsi_host_alloc()
397 shost->host_no = index; in scsi_host_alloc()
399 shost->dma_channel = 0xff; in scsi_host_alloc()
402 shost->max_channel = 0; in scsi_host_alloc()
403 shost->max_id = 8; in scsi_host_alloc()
404 shost->max_lun = 8; in scsi_host_alloc()
407 shost->transportt = &blank_transport_template; in scsi_host_alloc()
415 shost->max_cmd_len = 12; in scsi_host_alloc()
416 shost->hostt = sht; in scsi_host_alloc()
417 shost->this_id = sht->this_id; in scsi_host_alloc()
418 shost->can_queue = sht->can_queue; in scsi_host_alloc()
419 shost->sg_tablesize = sht->sg_tablesize; in scsi_host_alloc()
420 shost->sg_prot_tablesize = sht->sg_prot_tablesize; in scsi_host_alloc()
421 shost->cmd_per_lun = sht->cmd_per_lun; in scsi_host_alloc()
422 shost->unchecked_isa_dma = sht->unchecked_isa_dma; in scsi_host_alloc()
423 shost->no_write_same = sht->no_write_same; in scsi_host_alloc()
424 shost->host_tagset = sht->host_tagset; in scsi_host_alloc()
427 shost->eh_deadline = -1; in scsi_host_alloc()
429 shost_printk(KERN_WARNING, shost, in scsi_host_alloc()
432 shost->eh_deadline = INT_MAX; in scsi_host_alloc()
434 shost->eh_deadline = shost_eh_deadline * HZ; in scsi_host_alloc()
438 shost->active_mode = MODE_INITIATOR; in scsi_host_alloc()
440 shost->active_mode = sht->supported_mode; in scsi_host_alloc()
443 shost->max_host_blocked = sht->max_host_blocked; in scsi_host_alloc()
445 shost->max_host_blocked = SCSI_DEFAULT_HOST_BLOCKED; in scsi_host_alloc()
452 shost->max_sectors = sht->max_sectors; in scsi_host_alloc()
454 shost->max_sectors = SCSI_DEFAULT_MAX_SECTORS; in scsi_host_alloc()
457 shost->max_segment_size = sht->max_segment_size; in scsi_host_alloc()
459 shost->max_segment_size = BLK_MAX_SEGMENT_SIZE; in scsi_host_alloc()
465 shost->dma_boundary = sht->dma_boundary; in scsi_host_alloc()
467 shost->dma_boundary = 0xffffffff; in scsi_host_alloc()
470 shost->virt_boundary_mask = sht->virt_boundary_mask; in scsi_host_alloc()
472 device_initialize(&shost->shost_gendev); in scsi_host_alloc()
473 dev_set_name(&shost->shost_gendev, "host%d", shost->host_no); in scsi_host_alloc()
474 shost->shost_gendev.bus = &scsi_bus_type; in scsi_host_alloc()
475 shost->shost_gendev.type = &scsi_host_type; in scsi_host_alloc()
477 device_initialize(&shost->shost_dev); in scsi_host_alloc()
478 shost->shost_dev.parent = &shost->shost_gendev; in scsi_host_alloc()
479 shost->shost_dev.class = &shost_class; in scsi_host_alloc()
480 dev_set_name(&shost->shost_dev, "host%d", shost->host_no); in scsi_host_alloc()
481 shost->shost_dev.groups = scsi_sysfs_shost_attr_groups; in scsi_host_alloc()
483 shost->ehandler = kthread_run(scsi_error_handler, shost, in scsi_host_alloc()
484 "scsi_eh_%d", shost->host_no); in scsi_host_alloc()
485 if (IS_ERR(shost->ehandler)) { in scsi_host_alloc()
486 shost_printk(KERN_WARNING, shost, in scsi_host_alloc()
488 PTR_ERR(shost->ehandler)); in scsi_host_alloc()
492 shost->tmf_work_q = alloc_workqueue("scsi_tmf_%d", in scsi_host_alloc()
494 1, shost->host_no); in scsi_host_alloc()
495 if (!shost->tmf_work_q) { in scsi_host_alloc()
496 shost_printk(KERN_WARNING, shost, in scsi_host_alloc()
500 scsi_proc_hostdir_add(shost->hostt); in scsi_host_alloc()
501 return shost; in scsi_host_alloc()
504 kthread_stop(shost->ehandler); in scsi_host_alloc()
506 ida_simple_remove(&host_index_ida, shost->host_no); in scsi_host_alloc()
508 kfree(shost); in scsi_host_alloc()
536 struct Scsi_Host *shost = NULL; in scsi_host_lookup() local
541 shost = scsi_host_get(class_to_shost(cdev)); in scsi_host_lookup()
544 return shost; in scsi_host_lookup()
552 struct Scsi_Host *scsi_host_get(struct Scsi_Host *shost) in scsi_host_get() argument
554 if ((shost->shost_state == SHOST_DEL) || in scsi_host_get()
555 !get_device(&shost->shost_gendev)) in scsi_host_get()
557 return shost; in scsi_host_get()
577 int scsi_host_busy(struct Scsi_Host *shost) in scsi_host_busy() argument
581 blk_mq_tagset_busy_iter(&shost->tag_set, in scsi_host_busy()
591 void scsi_host_put(struct Scsi_Host *shost) in scsi_host_put() argument
593 put_device(&shost->shost_gendev); in scsi_host_put()
624 int scsi_queue_work(struct Scsi_Host *shost, struct work_struct *work) in scsi_queue_work() argument
626 if (unlikely(!shost->work_q)) { in scsi_queue_work()
627 shost_printk(KERN_ERR, shost, in scsi_queue_work()
629 "when no workqueue created.\n", shost->hostt->name); in scsi_queue_work()
635 return queue_work(shost->work_q, work); in scsi_queue_work()
643 void scsi_flush_work(struct Scsi_Host *shost) in scsi_flush_work() argument
645 if (!shost->work_q) { in scsi_flush_work()
646 shost_printk(KERN_ERR, shost, in scsi_flush_work()
648 "when no workqueue created.\n", shost->hostt->name); in scsi_flush_work()
653 flush_workqueue(shost->work_q); in scsi_flush_work()
678 void scsi_host_complete_all_commands(struct Scsi_Host *shost, int status) in scsi_host_complete_all_commands() argument
680 blk_mq_tagset_busy_iter(&shost->tag_set, complete_all_cmds_iter, in scsi_host_complete_all_commands()
708 void scsi_host_busy_iter(struct Scsi_Host *shost, in scsi_host_busy_iter() argument
717 blk_mq_tagset_busy_iter(&shost->tag_set, __scsi_host_busy_iter_fn, in scsi_host_busy_iter()