Lines Matching +full:os +full:- +full:initiated

1 // SPDX-License-Identifier: GPL-2.0+
7 * (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
10 * (c) 2000 David L. Brown, Jr. (usb-storage@davidb.org)
20 * similar to commands in the SCSI-II and ATAPI specifications.
23 * exhibits class-specific exemptions from the USB specification.
32 #include <linux/dma-mapping.h>
65 return us->scsi_name; in host_info()
70 struct us_data *us = host_to_us(sdev->host); in slave_alloc()
77 sdev->inquiry_len = 36; in slave_alloc()
81 * We'll play it safe by requiring 512-byte alignment always. in slave_alloc()
83 blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1)); in slave_alloc()
86 if (us->protocol == USB_PR_BULK && us->max_lun > 0) in slave_alloc()
87 sdev->sdev_bflags |= BLIST_FORCELUN; in slave_alloc()
94 struct us_data *us = host_to_us(sdev->host); in slave_configure()
95 struct device *dev = us->pusb_dev->bus->sysdev; in slave_configure()
102 if (us->fflags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) { in slave_configure()
105 if (us->fflags & US_FL_MAX_SECTORS_MIN) in slave_configure()
107 if (queue_max_hw_sectors(sdev->request_queue) > max_sectors) in slave_configure()
108 blk_queue_max_hw_sectors(sdev->request_queue, in slave_configure()
110 } else if (sdev->type == TYPE_TAPE) { in slave_configure()
116 blk_queue_max_hw_sectors(sdev->request_queue, 0x7FFFFF); in slave_configure()
117 } else if (us->pusb_dev->speed >= USB_SPEED_SUPER) { in slave_configure()
122 blk_queue_max_hw_sectors(sdev->request_queue, 2048); in slave_configure()
129 blk_queue_max_hw_sectors(sdev->request_queue, in slave_configure()
130 min_t(size_t, queue_max_hw_sectors(sdev->request_queue), in slave_configure()
138 if (!hcd_uses_dma(bus_to_hcd(us->pusb_dev->bus)) || in slave_configure()
139 (bus_to_hcd(us->pusb_dev->bus)->localmem_pool != NULL)) in slave_configure()
140 blk_queue_bounce_limit(sdev->request_queue, BLK_BOUNCE_HIGH); in slave_configure()
147 if (sdev->type == TYPE_DISK) { in slave_configure()
151 * all their devices -- primarily makers of cell phones in slave_configure()
157 switch (le16_to_cpu(us->pusb_dev->descriptor.idVendor)) { in slave_configure()
162 if (!(us->fflags & (US_FL_FIX_CAPACITY | in slave_configure()
164 us->fflags |= US_FL_CAPACITY_HEURISTICS; in slave_configure()
169 * Disk-type devices use MODE SENSE(6) if the protocol in slave_configure()
173 if (us->subclass != USB_SC_SCSI && us->subclass != USB_SC_CYP_ATACB) in slave_configure()
174 sdev->use_10_for_ms = 1; in slave_configure()
180 sdev->use_192_bytes_for_3f = 1; in slave_configure()
187 sdev->read_before_ms = 1; in slave_configure()
192 * is write-protected. Now that we tell the sd driver in slave_configure()
193 * to do a 192-byte transfer with this command the in slave_configure()
196 * devices are write-enabled. in slave_configure()
198 if (us->fflags & US_FL_NO_WP_DETECT) in slave_configure()
199 sdev->skip_ms_page_3f = 1; in slave_configure()
205 sdev->skip_ms_page_8 = 1; in slave_configure()
211 sdev->skip_vpd_pages = !sdev->try_vpd_pages; in slave_configure()
214 sdev->no_report_opcodes = 1; in slave_configure()
217 sdev->no_write_same = 1; in slave_configure()
224 if (us->fflags & US_FL_FIX_CAPACITY) in slave_configure()
225 sdev->fix_capacity = 1; in slave_configure()
232 if (us->fflags & US_FL_CAPACITY_HEURISTICS) in slave_configure()
233 sdev->guess_capacity = 1; in slave_configure()
236 if (us->fflags & US_FL_NO_READ_CAPACITY_16) in slave_configure()
237 sdev->no_read_capacity_16 = 1; in slave_configure()
245 if (!(us->fflags & US_FL_NEEDS_CAP16)) in slave_configure()
246 sdev->try_rc_10_first = 1; in slave_configure()
252 if (sdev->scsi_level > SCSI_SPC_2 && in slave_configure()
253 !(us->fflags & US_FL_BAD_SENSE)) in slave_configure()
254 us->fflags |= US_FL_SANE_SENSE; in slave_configure()
257 * USB-IDE bridges tend to report SK = 0x04 (Non-recoverable in slave_configure()
258 * Hardware Error) when any low-level error occurs, in slave_configure()
264 sdev->retry_hwerror = 1; in slave_configure()
268 * automatically, requiring a START-STOP UNIT command. in slave_configure()
270 sdev->allow_restart = 1; in slave_configure()
277 sdev->last_sector_bug = 1; in slave_configure()
280 * Enable last-sector hacks for single-target devices using in slave_configure()
281 * the Bulk-only transport, unless we already know the in slave_configure()
284 if (!(us->fflags & (US_FL_FIX_CAPACITY | US_FL_CAPACITY_OK | in slave_configure()
286 us->protocol == USB_PR_BULK) in slave_configure()
287 us->use_last_sector_hacks = 1; in slave_configure()
290 if (us->fflags & US_FL_WRITE_CACHE) in slave_configure()
291 sdev->wce_default_on = 1; in slave_configure()
293 /* A few buggy USB-ATA bridges don't understand FUA */ in slave_configure()
294 if (us->fflags & US_FL_BROKEN_FUA) in slave_configure()
295 sdev->broken_fua = 1; in slave_configure()
298 if (us->fflags & US_FL_ALWAYS_SYNC) { in slave_configure()
300 sdev->skip_ms_page_8 = 1; in slave_configure()
301 sdev->skip_ms_page_3f = 1; in slave_configure()
303 sdev->wce_default_on = 1; in slave_configure()
308 * Non-disk-type devices don't need to ignore any pages in slave_configure()
309 * or to force 192-byte transfer lengths for MODE SENSE. in slave_configure()
312 sdev->use_10_for_ms = 1; in slave_configure()
315 if (us->fflags & US_FL_NO_READ_DISC_INFO) in slave_configure()
316 sdev->no_read_disc_info = 1; in slave_configure()
324 * be single-LUN. in slave_configure()
326 if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_CBI) && in slave_configure()
327 sdev->scsi_level == SCSI_UNKNOWN) in slave_configure()
328 us->max_lun = 0; in slave_configure()
331 * Some devices choke when they receive a PREVENT-ALLOW MEDIUM in slave_configure()
334 if (us->fflags & US_FL_NOT_LOCKABLE) in slave_configure()
335 sdev->lockable = 0; in slave_configure()
346 struct us_data *us = host_to_us(dev_to_shost(starget->dev.parent)); in target_alloc()
354 starget->no_report_luns = 1; in target_alloc()
365 if (us->subclass == USB_SC_UFI) in target_alloc()
366 starget->pdt_1f_for_no_lun = 1; in target_alloc()
376 struct us_data *us = host_to_us(srb->device->host); in queuecommand_lck()
378 /* check for state-transition errors */ in queuecommand_lck()
379 if (us->srb != NULL) { in queuecommand_lck()
380 dev_err(&us->pusb_intf->dev, in queuecommand_lck()
381 "Error in %s: us->srb = %p\n", __func__, us->srb); in queuecommand_lck()
386 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) { in queuecommand_lck()
388 srb->result = DID_NO_CONNECT << 16; in queuecommand_lck()
393 if ((us->fflags & US_FL_NO_ATA_1X) && in queuecommand_lck()
394 (srb->cmnd[0] == ATA_12 || srb->cmnd[0] == ATA_16)) { in queuecommand_lck()
395 memcpy(srb->sense_buffer, usb_stor_sense_invalidCDB, in queuecommand_lck()
397 srb->result = SAM_STAT_CHECK_CONDITION; in queuecommand_lck()
403 us->srb = srb; in queuecommand_lck()
404 complete(&us->cmnd_ready); in queuecommand_lck()
419 * us->srb together with the TIMED_OUT, RESETTING, and ABORTING in DEF_SCSI_QCMD()
425 if (!us->srb) { in DEF_SCSI_QCMD()
427 usb_stor_dbg(us, "-- nothing to abort\n"); in DEF_SCSI_QCMD()
432 if (srb_match && us->srb != srb_match) { in DEF_SCSI_QCMD()
434 usb_stor_dbg(us, "-- pending command mismatch\n"); in DEF_SCSI_QCMD()
443 * with an auto-reset that begins as soon as we release the lock. in DEF_SCSI_QCMD()
445 set_bit(US_FLIDX_TIMED_OUT, &us->dflags); in DEF_SCSI_QCMD()
446 if (!test_bit(US_FLIDX_RESETTING, &us->dflags)) { in DEF_SCSI_QCMD()
447 set_bit(US_FLIDX_ABORTING, &us->dflags); in DEF_SCSI_QCMD()
453 wait_for_completion(&us->notify); in DEF_SCSI_QCMD()
459 struct us_data *us = host_to_us(srb->device->host); in command_abort()
471 struct us_data *us = host_to_us(srb->device->host); in device_reset()
480 mutex_lock(&(us->dev_mutex)); in device_reset()
481 result = us->transport_reset(us); in device_reset()
482 mutex_unlock(&us->dev_mutex); in device_reset()
490 struct us_data *us = host_to_us(srb->device->host); in bus_reset()
500 * Report a driver-initiated device reset to the SCSI layer.
501 * Calling this for a SCSI-initiated reset is unnecessary but harmless.
510 if (us->fflags & US_FL_SCM_MULT_TARG) { in usb_stor_report_device_reset()
511 for (i = 1; i < host->max_id; ++i) in usb_stor_report_device_reset()
517 * Report a driver-initiated bus reset to the SCSI layer.
518 * Calling this for a SCSI-initiated reset is unnecessary but harmless.
546 seq_printf(m, " Host scsi%d: usb-storage\n", host->host_no); in show_info()
549 if (us->pusb_dev->manufacturer) in show_info()
550 string = us->pusb_dev->manufacturer; in show_info()
551 else if (us->unusual_dev->vendorName) in show_info()
552 string = us->unusual_dev->vendorName; in show_info()
556 if (us->pusb_dev->product) in show_info()
557 string = us->pusb_dev->product; in show_info()
558 else if (us->unusual_dev->productName) in show_info()
559 string = us->unusual_dev->productName; in show_info()
563 if (us->pusb_dev->serial) in show_info()
564 string = us->pusb_dev->serial; in show_info()
570 seq_printf(m, " Protocol: %s\n", us->protocol_name); in show_info()
571 seq_printf(m, " Transport: %s\n", us->transport_name); in show_info()
577 if (us->fflags & value) seq_printf(m, " " #name); in show_info()
593 return sprintf(buf, "%u\n", queue_max_hw_sectors(sdev->request_queue)); in max_sectors_show()
604 blk_queue_max_hw_sectors(sdev->request_queue, ms); in max_sectors_store()
607 return -EINVAL; in max_sectors_store()
624 .name = "usb-storage",
625 .proc_name = "usb-storage",
630 /* command interface -- queued only */
642 .this_id = -1,
657 * only an 8-bit register to hold the number of sectors in one transfer
666 * and Apple Mac OS X 10.11 limiting transfers to 256 sectors for USB2
688 sht->name = name; in usb_stor_host_template_init()
689 sht->proc_name = name; in usb_stor_host_template_init()
690 sht->module = owner; in usb_stor_host_template_init()