Lines Matching refs:devinfo

77 				struct uas_dev_info *devinfo);
80 static void uas_free_streams(struct uas_dev_info *devinfo);
99 struct uas_dev_info *devinfo = in uas_do_work() local
106 spin_lock_irqsave(&devinfo->lock, flags); in uas_do_work()
108 if (devinfo->resetting) in uas_do_work()
111 for (i = 0; i < devinfo->qdepth; i++) { in uas_do_work()
112 if (!devinfo->cmnd[i]) in uas_do_work()
115 cmnd = devinfo->cmnd[i]; in uas_do_work()
125 queue_work(workqueue, &devinfo->work); in uas_do_work()
128 spin_unlock_irqrestore(&devinfo->lock, flags); in uas_do_work()
133 struct uas_dev_info *devinfo = in uas_scan_work() local
135 struct Scsi_Host *shost = usb_get_intfdata(devinfo->intf); in uas_scan_work()
137 dev_dbg(&devinfo->intf->dev, "starting scan\n"); in uas_scan_work()
139 dev_dbg(&devinfo->intf->dev, "scan complete\n"); in uas_scan_work()
145 struct uas_dev_info *devinfo = cmnd->device->hostdata; in uas_add_work() local
147 lockdep_assert_held(&devinfo->lock); in uas_add_work()
149 queue_work(workqueue, &devinfo->work); in uas_add_work()
152 static void uas_zap_pending(struct uas_dev_info *devinfo, int result) in uas_zap_pending() argument
159 spin_lock_irqsave(&devinfo->lock, flags); in uas_zap_pending()
160 for (i = 0; i < devinfo->qdepth; i++) { in uas_zap_pending()
161 if (!devinfo->cmnd[i]) in uas_zap_pending()
164 cmnd = devinfo->cmnd[i]; in uas_zap_pending()
173 spin_unlock_irqrestore(&devinfo->lock, flags); in uas_zap_pending()
247 struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; in uas_try_complete() local
249 lockdep_assert_held(&devinfo->lock); in uas_try_complete()
255 devinfo->cmnd[cmdinfo->uas_tag - 1] = NULL; in uas_try_complete()
301 struct uas_dev_info *devinfo = (struct uas_dev_info *)shost->hostdata; in uas_stat_cmplt() local
311 spin_lock_irqsave(&devinfo->lock, flags); in uas_stat_cmplt()
313 if (devinfo->resetting) in uas_stat_cmplt()
323 if (idx >= MAX_CMNDS || !devinfo->cmnd[idx]) { in uas_stat_cmplt()
329 cmnd = devinfo->cmnd[idx]; in uas_stat_cmplt()
379 spin_unlock_irqrestore(&devinfo->lock, flags); in uas_stat_cmplt()
396 struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; in uas_data_cmplt() local
401 spin_lock_irqsave(&devinfo->lock, flags); in uas_data_cmplt()
411 if (devinfo->resetting) in uas_data_cmplt()
431 spin_unlock_irqrestore(&devinfo->lock, flags); in uas_data_cmplt()
442 static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp, in uas_alloc_data_urb() argument
446 struct usb_device *udev = devinfo->udev; in uas_alloc_data_urb()
451 ? devinfo->data_in_pipe : devinfo->data_out_pipe; in uas_alloc_data_urb()
457 if (devinfo->use_streams) in uas_alloc_data_urb()
465 static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp, in uas_alloc_sense_urb() argument
468 struct usb_device *udev = devinfo->udev; in uas_alloc_sense_urb()
480 usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, sizeof(*iu), in uas_alloc_sense_urb()
482 if (devinfo->use_streams) in uas_alloc_sense_urb()
492 static struct urb *uas_alloc_cmd_urb(struct uas_dev_info *devinfo, gfp_t gfp, in uas_alloc_cmd_urb() argument
495 struct usb_device *udev = devinfo->udev; in uas_alloc_cmd_urb()
520 usb_fill_bulk_urb(urb, udev, devinfo->cmd_pipe, iu, sizeof(*iu) + len, in uas_alloc_cmd_urb()
538 struct uas_dev_info *devinfo = cmnd->device->hostdata; in uas_submit_sense_urb() local
542 urb = uas_alloc_sense_urb(devinfo, gfp, cmnd); in uas_submit_sense_urb()
545 usb_anchor_urb(urb, &devinfo->sense_urbs); in uas_submit_sense_urb()
557 struct uas_dev_info *devinfo) in uas_submit_urbs() argument
563 lockdep_assert_held(&devinfo->lock); in uas_submit_urbs()
572 cmdinfo->data_in_urb = uas_alloc_data_urb(devinfo, GFP_ATOMIC, in uas_submit_urbs()
580 usb_anchor_urb(cmdinfo->data_in_urb, &devinfo->data_urbs); in uas_submit_urbs()
592 cmdinfo->data_out_urb = uas_alloc_data_urb(devinfo, GFP_ATOMIC, in uas_submit_urbs()
600 usb_anchor_urb(cmdinfo->data_out_urb, &devinfo->data_urbs); in uas_submit_urbs()
612 cmdinfo->cmd_urb = uas_alloc_cmd_urb(devinfo, GFP_ATOMIC, cmnd); in uas_submit_urbs()
619 usb_anchor_urb(cmdinfo->cmd_urb, &devinfo->cmd_urbs); in uas_submit_urbs()
637 struct uas_dev_info *devinfo = sdev->hostdata; in uas_queuecommand_lck() local
646 if ((devinfo->flags & US_FL_NO_ATA_1X) && in uas_queuecommand_lck()
655 spin_lock_irqsave(&devinfo->lock, flags); in uas_queuecommand_lck()
657 if (devinfo->resetting) { in uas_queuecommand_lck()
664 for (idx = 0; idx < devinfo->qdepth; idx++) { in uas_queuecommand_lck()
665 if (!devinfo->cmnd[idx]) in uas_queuecommand_lck()
668 if (idx == devinfo->qdepth) { in uas_queuecommand_lck()
669 spin_unlock_irqrestore(&devinfo->lock, flags); in uas_queuecommand_lck()
691 if (!devinfo->use_streams) in uas_queuecommand_lck()
694 err = uas_submit_urbs(cmnd, devinfo); in uas_queuecommand_lck()
708 spin_unlock_irqrestore(&devinfo->lock, flags); in uas_queuecommand_lck()
714 devinfo->cmnd[idx] = cmnd; in uas_queuecommand_lck()
716 spin_unlock_irqrestore(&devinfo->lock, flags); in uas_queuecommand_lck()
730 struct uas_dev_info *devinfo = (void *)cmnd->device->hostdata; in DEF_SCSI_QCMD() local
735 spin_lock_irqsave(&devinfo->lock, flags); in DEF_SCSI_QCMD()
743 devinfo->cmnd[cmdinfo->uas_tag - 1] = NULL; in DEF_SCSI_QCMD()
751 spin_unlock_irqrestore(&devinfo->lock, flags); in DEF_SCSI_QCMD()
768 struct uas_dev_info *devinfo = sdev->hostdata; in uas_eh_device_reset_handler() local
769 struct usb_device *udev = devinfo->udev; in uas_eh_device_reset_handler()
773 err = usb_lock_device_for_reset(udev, devinfo->intf); in uas_eh_device_reset_handler()
782 spin_lock_irqsave(&devinfo->lock, flags); in uas_eh_device_reset_handler()
783 devinfo->resetting = 1; in uas_eh_device_reset_handler()
784 spin_unlock_irqrestore(&devinfo->lock, flags); in uas_eh_device_reset_handler()
786 usb_kill_anchored_urbs(&devinfo->cmd_urbs); in uas_eh_device_reset_handler()
787 usb_kill_anchored_urbs(&devinfo->sense_urbs); in uas_eh_device_reset_handler()
788 usb_kill_anchored_urbs(&devinfo->data_urbs); in uas_eh_device_reset_handler()
789 uas_zap_pending(devinfo, DID_RESET); in uas_eh_device_reset_handler()
793 spin_lock_irqsave(&devinfo->lock, flags); in uas_eh_device_reset_handler()
794 devinfo->resetting = 0; in uas_eh_device_reset_handler()
795 spin_unlock_irqrestore(&devinfo->lock, flags); in uas_eh_device_reset_handler()
811 struct uas_dev_info *devinfo = (struct uas_dev_info *) in uas_target_alloc() local
814 if (devinfo->flags & US_FL_NO_REPORT_LUNS) in uas_target_alloc()
822 struct uas_dev_info *devinfo = in uas_slave_alloc() local
825 sdev->hostdata = devinfo; in uas_slave_alloc()
834 if (devinfo->flags & US_FL_MAX_SECTORS_64) in uas_slave_alloc()
836 else if (devinfo->flags & US_FL_MAX_SECTORS_240) in uas_slave_alloc()
844 struct uas_dev_info *devinfo = sdev->hostdata; in uas_slave_configure() local
846 if (devinfo->flags & US_FL_NO_REPORT_OPCODES) in uas_slave_configure()
850 if (devinfo->flags & US_FL_BROKEN_FUA) in uas_slave_configure()
854 if (devinfo->flags & US_FL_ALWAYS_SYNC) { in uas_slave_configure()
861 if (devinfo->flags & US_FL_NO_READ_CAPACITY_16) in uas_slave_configure()
865 if (devinfo->flags & US_FL_NO_SAME) in uas_slave_configure()
872 if (devinfo->flags & US_FL_FIX_CAPACITY) in uas_slave_configure()
878 if (devinfo->flags & US_FL_CAPACITY_HEURISTICS) in uas_slave_configure()
890 if (devinfo->flags & US_FL_NO_WP_DETECT) in uas_slave_configure()
893 scsi_change_queue_depth(sdev, devinfo->qdepth - 2); in uas_slave_configure()
941 static int uas_configure_endpoints(struct uas_dev_info *devinfo) in uas_configure_endpoints() argument
944 struct usb_device *udev = devinfo->udev; in uas_configure_endpoints()
947 r = uas_find_endpoints(devinfo->intf->cur_altsetting, eps); in uas_configure_endpoints()
951 devinfo->cmd_pipe = usb_sndbulkpipe(udev, in uas_configure_endpoints()
953 devinfo->status_pipe = usb_rcvbulkpipe(udev, in uas_configure_endpoints()
955 devinfo->data_in_pipe = usb_rcvbulkpipe(udev, in uas_configure_endpoints()
957 devinfo->data_out_pipe = usb_sndbulkpipe(udev, in uas_configure_endpoints()
961 devinfo->qdepth = 32; in uas_configure_endpoints()
962 devinfo->use_streams = 0; in uas_configure_endpoints()
964 devinfo->qdepth = usb_alloc_streams(devinfo->intf, eps + 1, in uas_configure_endpoints()
966 if (devinfo->qdepth < 0) in uas_configure_endpoints()
967 return devinfo->qdepth; in uas_configure_endpoints()
968 devinfo->use_streams = 1; in uas_configure_endpoints()
974 static void uas_free_streams(struct uas_dev_info *devinfo) in uas_free_streams() argument
976 struct usb_device *udev = devinfo->udev; in uas_free_streams()
979 eps[0] = usb_pipe_endpoint(udev, devinfo->status_pipe); in uas_free_streams()
980 eps[1] = usb_pipe_endpoint(udev, devinfo->data_in_pipe); in uas_free_streams()
981 eps[2] = usb_pipe_endpoint(udev, devinfo->data_out_pipe); in uas_free_streams()
982 usb_free_streams(devinfo->intf, eps, 3, GFP_NOIO); in uas_free_streams()
989 struct uas_dev_info *devinfo; in uas_probe() local
1010 devinfo = (struct uas_dev_info *)shost->hostdata; in uas_probe()
1011 devinfo->intf = intf; in uas_probe()
1012 devinfo->udev = udev; in uas_probe()
1013 devinfo->resetting = 0; in uas_probe()
1014 devinfo->shutdown = 0; in uas_probe()
1015 devinfo->flags = dev_flags; in uas_probe()
1016 init_usb_anchor(&devinfo->cmd_urbs); in uas_probe()
1017 init_usb_anchor(&devinfo->sense_urbs); in uas_probe()
1018 init_usb_anchor(&devinfo->data_urbs); in uas_probe()
1019 spin_lock_init(&devinfo->lock); in uas_probe()
1020 INIT_WORK(&devinfo->work, uas_do_work); in uas_probe()
1021 INIT_WORK(&devinfo->scan_work, uas_scan_work); in uas_probe()
1023 result = uas_configure_endpoints(devinfo); in uas_probe()
1031 shost->can_queue = devinfo->qdepth - 2; in uas_probe()
1039 schedule_work(&devinfo->scan_work); in uas_probe()
1044 uas_free_streams(devinfo); in uas_probe()
1053 static int uas_cmnd_list_empty(struct uas_dev_info *devinfo) in uas_cmnd_list_empty() argument
1058 spin_lock_irqsave(&devinfo->lock, flags); in uas_cmnd_list_empty()
1060 for (i = 0; i < devinfo->qdepth; i++) { in uas_cmnd_list_empty()
1061 if (devinfo->cmnd[i]) { in uas_cmnd_list_empty()
1067 spin_unlock_irqrestore(&devinfo->lock, flags); in uas_cmnd_list_empty()
1077 static int uas_wait_for_pending_cmnds(struct uas_dev_info *devinfo) in uas_wait_for_pending_cmnds() argument
1084 flush_work(&devinfo->work); in uas_wait_for_pending_cmnds()
1086 r = usb_wait_anchor_empty_timeout(&devinfo->sense_urbs, 5000); in uas_wait_for_pending_cmnds()
1090 r = usb_wait_anchor_empty_timeout(&devinfo->data_urbs, 500); in uas_wait_for_pending_cmnds()
1096 } while (!uas_cmnd_list_empty(devinfo)); in uas_wait_for_pending_cmnds()
1104 struct uas_dev_info *devinfo = (struct uas_dev_info *)shost->hostdata; in uas_pre_reset() local
1107 if (devinfo->shutdown) in uas_pre_reset()
1115 if (uas_wait_for_pending_cmnds(devinfo) != 0) { in uas_pre_reset()
1121 uas_free_streams(devinfo); in uas_pre_reset()
1129 struct uas_dev_info *devinfo = (struct uas_dev_info *)shost->hostdata; in uas_post_reset() local
1133 if (devinfo->shutdown) in uas_post_reset()
1136 err = uas_configure_endpoints(devinfo); in uas_post_reset()
1155 struct uas_dev_info *devinfo = (struct uas_dev_info *)shost->hostdata; in uas_suspend() local
1157 if (uas_wait_for_pending_cmnds(devinfo) != 0) { in uas_suspend()
1173 struct uas_dev_info *devinfo = (struct uas_dev_info *)shost->hostdata; in uas_reset_resume() local
1177 err = uas_configure_endpoints(devinfo); in uas_reset_resume()
1195 struct uas_dev_info *devinfo = (struct uas_dev_info *)shost->hostdata; in uas_disconnect() local
1198 spin_lock_irqsave(&devinfo->lock, flags); in uas_disconnect()
1199 devinfo->resetting = 1; in uas_disconnect()
1200 spin_unlock_irqrestore(&devinfo->lock, flags); in uas_disconnect()
1202 cancel_work_sync(&devinfo->work); in uas_disconnect()
1203 usb_kill_anchored_urbs(&devinfo->cmd_urbs); in uas_disconnect()
1204 usb_kill_anchored_urbs(&devinfo->sense_urbs); in uas_disconnect()
1205 usb_kill_anchored_urbs(&devinfo->data_urbs); in uas_disconnect()
1206 uas_zap_pending(devinfo, DID_NO_CONNECT); in uas_disconnect()
1212 cancel_work_sync(&devinfo->scan_work); in uas_disconnect()
1215 uas_free_streams(devinfo); in uas_disconnect()
1229 struct uas_dev_info *devinfo = (struct uas_dev_info *)shost->hostdata; in uas_shutdown() local
1234 devinfo->shutdown = 1; in uas_shutdown()
1235 uas_free_streams(devinfo); in uas_shutdown()