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-[email protected])
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>
64 return us->scsi_name; in host_info()
69 struct us_data *us = host_to_us(sdev->host); in sdev_init()
76 sdev->inquiry_len = 36; in sdev_init()
79 if (us->protocol == USB_PR_BULK && us->max_lun > 0) in sdev_init()
80 sdev->sdev_bflags |= BLIST_FORCELUN; in sdev_init()
86 sdev->sdev_bflags |= BLIST_SKIP_IO_HINTS; in sdev_init()
93 struct us_data *us = host_to_us(sdev->host); in sdev_configure()
94 struct device *dev = us->pusb_dev->bus->sysdev; in sdev_configure()
101 if (us->fflags & (US_FL_MAX_SECTORS_64 | US_FL_MAX_SECTORS_MIN)) { in sdev_configure()
104 if (us->fflags & US_FL_MAX_SECTORS_MIN) in sdev_configure()
106 lim->max_hw_sectors = min(lim->max_hw_sectors, max_sectors); in sdev_configure()
107 } else if (sdev->type == TYPE_TAPE) { in sdev_configure()
113 lim->max_hw_sectors = 0x7FFFFF; in sdev_configure()
114 } else if (us->pusb_dev->speed >= USB_SPEED_SUPER) { in sdev_configure()
119 lim->max_hw_sectors = 2048; in sdev_configure()
126 lim->max_hw_sectors = min_t(size_t, in sdev_configure()
127 lim->max_hw_sectors, dma_max_mapping_size(dev) >> SECTOR_SHIFT); in sdev_configure()
134 if (sdev->type == TYPE_DISK) { in sdev_configure()
138 * all their devices -- primarily makers of cell phones in sdev_configure()
144 switch (le16_to_cpu(us->pusb_dev->descriptor.idVendor)) { in sdev_configure()
149 if (!(us->fflags & (US_FL_FIX_CAPACITY | in sdev_configure()
151 us->fflags |= US_FL_CAPACITY_HEURISTICS; in sdev_configure()
156 * Disk-type devices use MODE SENSE(6) if the protocol in sdev_configure()
160 if (us->subclass != USB_SC_SCSI && us->subclass != USB_SC_CYP_ATACB) in sdev_configure()
161 sdev->use_10_for_ms = 1; in sdev_configure()
167 sdev->use_192_bytes_for_3f = 1; in sdev_configure()
174 sdev->read_before_ms = 1; in sdev_configure()
179 * is write-protected. Now that we tell the sd driver in sdev_configure()
180 * to do a 192-byte transfer with this command the in sdev_configure()
183 * devices are write-enabled. in sdev_configure()
185 if (us->fflags & US_FL_NO_WP_DETECT) in sdev_configure()
186 sdev->skip_ms_page_3f = 1; in sdev_configure()
192 sdev->skip_ms_page_8 = 1; in sdev_configure()
198 sdev->skip_vpd_pages = !sdev->try_vpd_pages; in sdev_configure()
201 sdev->no_report_opcodes = 1; in sdev_configure()
204 sdev->no_write_same = 1; in sdev_configure()
211 if (us->fflags & US_FL_FIX_CAPACITY) in sdev_configure()
212 sdev->fix_capacity = 1; in sdev_configure()
219 if (us->fflags & US_FL_CAPACITY_HEURISTICS) in sdev_configure()
220 sdev->guess_capacity = 1; in sdev_configure()
223 if (us->fflags & US_FL_NO_READ_CAPACITY_16) in sdev_configure()
224 sdev->no_read_capacity_16 = 1; in sdev_configure()
232 if (!(us->fflags & US_FL_NEEDS_CAP16)) in sdev_configure()
233 sdev->try_rc_10_first = 1; in sdev_configure()
239 if (sdev->scsi_level > SCSI_SPC_2 && in sdev_configure()
240 !(us->fflags & US_FL_BAD_SENSE)) in sdev_configure()
241 us->fflags |= US_FL_SANE_SENSE; in sdev_configure()
244 * USB-IDE bridges tend to report SK = 0x04 (Non-recoverable in sdev_configure()
245 * Hardware Error) when any low-level error occurs, in sdev_configure()
251 sdev->retry_hwerror = 1; in sdev_configure()
255 * automatically, requiring a START-STOP UNIT command. in sdev_configure()
257 sdev->allow_restart = 1; in sdev_configure()
264 sdev->last_sector_bug = 1; in sdev_configure()
267 * Enable last-sector hacks for single-target devices using in sdev_configure()
268 * the Bulk-only transport, unless we already know the in sdev_configure()
271 if (!(us->fflags & (US_FL_FIX_CAPACITY | US_FL_CAPACITY_OK | in sdev_configure()
273 us->protocol == USB_PR_BULK) in sdev_configure()
274 us->use_last_sector_hacks = 1; in sdev_configure()
277 if (us->fflags & US_FL_WRITE_CACHE) in sdev_configure()
278 sdev->wce_default_on = 1; in sdev_configure()
280 /* A few buggy USB-ATA bridges don't understand FUA */ in sdev_configure()
281 if (us->fflags & US_FL_BROKEN_FUA) in sdev_configure()
282 sdev->broken_fua = 1; in sdev_configure()
285 if (us->fflags & US_FL_ALWAYS_SYNC) { in sdev_configure()
287 sdev->skip_ms_page_8 = 1; in sdev_configure()
288 sdev->skip_ms_page_3f = 1; in sdev_configure()
290 sdev->wce_default_on = 1; in sdev_configure()
295 * Non-disk-type devices don't need to ignore any pages in sdev_configure()
296 * or to force 192-byte transfer lengths for MODE SENSE. in sdev_configure()
299 sdev->use_10_for_ms = 1; in sdev_configure()
302 if (us->fflags & US_FL_NO_READ_DISC_INFO) in sdev_configure()
303 sdev->no_read_disc_info = 1; in sdev_configure()
311 * be single-LUN. in sdev_configure()
313 if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_CBI) && in sdev_configure()
314 sdev->scsi_level == SCSI_UNKNOWN) in sdev_configure()
315 us->max_lun = 0; in sdev_configure()
318 * Some devices choke when they receive a PREVENT-ALLOW MEDIUM in sdev_configure()
321 if (us->fflags & US_FL_NOT_LOCKABLE) in sdev_configure()
322 sdev->lockable = 0; in sdev_configure()
333 struct us_data *us = host_to_us(dev_to_shost(starget->dev.parent)); in target_alloc()
341 starget->no_report_luns = 1; in target_alloc()
352 if (us->subclass == USB_SC_UFI) in target_alloc()
353 starget->pdt_1f_for_no_lun = 1; in target_alloc()
363 struct us_data *us = host_to_us(srb->device->host); in queuecommand_lck()
365 /* check for state-transition errors */ in queuecommand_lck()
366 if (us->srb != NULL) { in queuecommand_lck()
367 dev_err(&us->pusb_intf->dev, in queuecommand_lck()
368 "Error in %s: us->srb = %p\n", __func__, us->srb); in queuecommand_lck()
373 if (test_bit(US_FLIDX_DISCONNECTING, &us->dflags)) { in queuecommand_lck()
375 srb->result = DID_NO_CONNECT << 16; in queuecommand_lck()
380 if ((us->fflags & US_FL_NO_ATA_1X) && in queuecommand_lck()
381 (srb->cmnd[0] == ATA_12 || srb->cmnd[0] == ATA_16)) { in queuecommand_lck()
382 memcpy(srb->sense_buffer, usb_stor_sense_invalidCDB, in queuecommand_lck()
384 srb->result = SAM_STAT_CHECK_CONDITION; in queuecommand_lck()
390 us->srb = srb; in queuecommand_lck()
391 complete(&us->cmnd_ready); in queuecommand_lck()
406 * us->srb together with the TIMED_OUT, RESETTING, and ABORTING in DEF_SCSI_QCMD()
412 if (!us->srb) { in DEF_SCSI_QCMD()
414 usb_stor_dbg(us, "-- nothing to abort\n"); in DEF_SCSI_QCMD()
419 if (srb_match && us->srb != srb_match) { in DEF_SCSI_QCMD()
421 usb_stor_dbg(us, "-- pending command mismatch\n"); in DEF_SCSI_QCMD()
430 * with an auto-reset that begins as soon as we release the lock. in DEF_SCSI_QCMD()
432 set_bit(US_FLIDX_TIMED_OUT, &us->dflags); in DEF_SCSI_QCMD()
433 if (!test_bit(US_FLIDX_RESETTING, &us->dflags)) { in DEF_SCSI_QCMD()
434 set_bit(US_FLIDX_ABORTING, &us->dflags); in DEF_SCSI_QCMD()
440 wait_for_completion(&us->notify); in DEF_SCSI_QCMD()
446 struct us_data *us = host_to_us(srb->device->host); in command_abort()
458 struct us_data *us = host_to_us(srb->device->host); in device_reset()
467 mutex_lock(&(us->dev_mutex)); in device_reset()
468 result = us->transport_reset(us); in device_reset()
469 mutex_unlock(&us->dev_mutex); in device_reset()
477 struct us_data *us = host_to_us(srb->device->host); in bus_reset()
487 * Report a driver-initiated device reset to the SCSI layer.
488 * Calling this for a SCSI-initiated reset is unnecessary but harmless.
497 if (us->fflags & US_FL_SCM_MULT_TARG) { in usb_stor_report_device_reset()
498 for (i = 1; i < host->max_id; ++i) in usb_stor_report_device_reset()
504 * Report a driver-initiated bus reset to the SCSI layer.
505 * Calling this for a SCSI-initiated reset is unnecessary but harmless.
533 seq_printf(m, " Host scsi%d: usb-storage\n", host->host_no); in show_info()
536 if (us->pusb_dev->manufacturer) in show_info()
537 string = us->pusb_dev->manufacturer; in show_info()
538 else if (us->unusual_dev->vendorName) in show_info()
539 string = us->unusual_dev->vendorName; in show_info()
543 if (us->pusb_dev->product) in show_info()
544 string = us->pusb_dev->product; in show_info()
545 else if (us->unusual_dev->productName) in show_info()
546 string = us->unusual_dev->productName; in show_info()
550 if (us->pusb_dev->serial) in show_info()
551 string = us->pusb_dev->serial; in show_info()
557 seq_printf(m, " Protocol: %s\n", us->protocol_name); in show_info()
558 seq_printf(m, " Transport: %s\n", us->transport_name); in show_info()
564 if (us->fflags & value) seq_printf(m, " " #name); in show_info()
580 return sprintf(buf, "%u\n", queue_max_hw_sectors(sdev->request_queue)); in max_sectors_show()
593 return -EINVAL; in max_sectors_store()
595 lim = queue_limits_start_update(sdev->request_queue); in max_sectors_store()
597 ret = queue_limits_commit_update_frozen(sdev->request_queue, &lim); in max_sectors_store()
617 .name = "usb-storage",
618 .proc_name = "usb-storage",
623 /* command interface -- queued only */
635 .this_id = -1,
646 * We'll play it safe by requiring 512-byte alignment always.
655 * only an 8-bit register to hold the number of sectors in one transfer
664 * and Apple Mac OS X 10.11 limiting transfers to 256 sectors for USB2
686 sht->name = name; in usb_stor_host_template_init()
687 sht->proc_name = name; in usb_stor_host_template_init()
688 sht->module = owner; in usb_stor_host_template_init()