Lines Matching refs:sdkp
108 static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
121 static void sd_set_flush_flag(struct scsi_disk *sdkp) in sd_set_flush_flag() argument
125 if (sdkp->WCE) { in sd_set_flush_flag()
127 if (sdkp->DPOFUA) in sd_set_flush_flag()
131 blk_queue_write_cache(sdkp->disk->queue, wc, fua); in sd_set_flush_flag()
139 struct scsi_disk *sdkp = to_scsi_disk(dev); in cache_type_store() local
140 struct scsi_device *sdp = sdkp->device; in cache_type_store()
156 sdkp->cache_override = 1; in cache_type_store()
158 sdkp->cache_override = 0; in cache_type_store()
166 wce = (ct & 0x02) && !sdkp->write_prot ? 1 : 0; in cache_type_store()
168 if (sdkp->cache_override) { in cache_type_store()
169 sdkp->WCE = wce; in cache_type_store()
170 sdkp->RCD = rcd; in cache_type_store()
171 sd_set_flush_flag(sdkp); in cache_type_store()
176 sdkp->max_retries, &data, NULL)) in cache_type_store()
194 sdkp->max_retries, &data, &sshdr)) { in cache_type_store()
196 sd_print_sense_hdr(sdkp, &sshdr); in cache_type_store()
199 sd_revalidate_disk(sdkp->disk); in cache_type_store()
207 struct scsi_disk *sdkp = to_scsi_disk(dev); in manage_start_stop_show() local
208 struct scsi_device *sdp = sdkp->device; in manage_start_stop_show()
221 struct scsi_disk *sdkp = to_scsi_disk(dev); in manage_system_start_stop_show() local
222 struct scsi_device *sdp = sdkp->device; in manage_system_start_stop_show()
232 struct scsi_disk *sdkp = to_scsi_disk(dev); in manage_system_start_stop_store() local
233 struct scsi_device *sdp = sdkp->device; in manage_system_start_stop_store()
252 struct scsi_disk *sdkp = to_scsi_disk(dev); in manage_runtime_start_stop_show() local
253 struct scsi_device *sdp = sdkp->device; in manage_runtime_start_stop_show()
263 struct scsi_disk *sdkp = to_scsi_disk(dev); in manage_runtime_start_stop_store() local
264 struct scsi_device *sdp = sdkp->device; in manage_runtime_start_stop_store()
282 struct scsi_disk *sdkp = to_scsi_disk(dev); in manage_shutdown_show() local
283 struct scsi_device *sdp = sdkp->device; in manage_shutdown_show()
292 struct scsi_disk *sdkp = to_scsi_disk(dev); in manage_shutdown_store() local
293 struct scsi_device *sdp = sdkp->device; in manage_shutdown_store()
311 struct scsi_disk *sdkp = to_scsi_disk(dev); in allow_restart_show() local
313 return sprintf(buf, "%u\n", sdkp->device->allow_restart); in allow_restart_show()
321 struct scsi_disk *sdkp = to_scsi_disk(dev); in allow_restart_store() local
322 struct scsi_device *sdp = sdkp->device; in allow_restart_store()
342 struct scsi_disk *sdkp = to_scsi_disk(dev); in cache_type_show() local
343 int ct = sdkp->RCD + 2*sdkp->WCE; in cache_type_show()
352 struct scsi_disk *sdkp = to_scsi_disk(dev); in FUA_show() local
354 return sprintf(buf, "%u\n", sdkp->DPOFUA); in FUA_show()
362 struct scsi_disk *sdkp = to_scsi_disk(dev); in protection_type_show() local
364 return sprintf(buf, "%u\n", sdkp->protection_type); in protection_type_show()
371 struct scsi_disk *sdkp = to_scsi_disk(dev); in protection_type_store() local
384 sdkp->protection_type = val; in protection_type_store()
394 struct scsi_disk *sdkp = to_scsi_disk(dev); in protection_mode_show() local
395 struct scsi_device *sdp = sdkp->device; in protection_mode_show()
398 dif = scsi_host_dif_capable(sdp->host, sdkp->protection_type); in protection_mode_show()
399 dix = scsi_host_dix_capable(sdp->host, sdkp->protection_type); in protection_mode_show()
416 struct scsi_disk *sdkp = to_scsi_disk(dev); in app_tag_own_show() local
418 return sprintf(buf, "%u\n", sdkp->ATO); in app_tag_own_show()
426 struct scsi_disk *sdkp = to_scsi_disk(dev); in thin_provisioning_show() local
428 return sprintf(buf, "%u\n", sdkp->lbpme); in thin_provisioning_show()
446 struct scsi_disk *sdkp = to_scsi_disk(dev); in provisioning_mode_show() local
448 return sprintf(buf, "%s\n", lbp_mode[sdkp->provisioning_mode]); in provisioning_mode_show()
455 struct scsi_disk *sdkp = to_scsi_disk(dev); in provisioning_mode_store() local
456 struct scsi_device *sdp = sdkp->device; in provisioning_mode_store()
462 if (sd_is_zoned(sdkp)) { in provisioning_mode_store()
463 sd_config_discard(sdkp, SD_LBP_DISABLE); in provisioning_mode_store()
474 sd_config_discard(sdkp, mode); in provisioning_mode_store()
492 struct scsi_disk *sdkp = to_scsi_disk(dev); in zeroing_mode_show() local
494 return sprintf(buf, "%s\n", zeroing_mode[sdkp->zeroing_mode]); in zeroing_mode_show()
501 struct scsi_disk *sdkp = to_scsi_disk(dev); in zeroing_mode_store() local
511 sdkp->zeroing_mode = mode; in zeroing_mode_store()
521 struct scsi_disk *sdkp = to_scsi_disk(dev); in max_medium_access_timeouts_show() local
523 return sprintf(buf, "%u\n", sdkp->max_medium_access_timeouts); in max_medium_access_timeouts_show()
531 struct scsi_disk *sdkp = to_scsi_disk(dev); in max_medium_access_timeouts_store() local
537 err = kstrtouint(buf, 10, &sdkp->max_medium_access_timeouts); in max_medium_access_timeouts_store()
547 struct scsi_disk *sdkp = to_scsi_disk(dev); in max_write_same_blocks_show() local
549 return sprintf(buf, "%u\n", sdkp->max_ws_blocks); in max_write_same_blocks_show()
556 struct scsi_disk *sdkp = to_scsi_disk(dev); in max_write_same_blocks_store() local
557 struct scsi_device *sdp = sdkp->device; in max_write_same_blocks_store()
576 sdkp->max_ws_blocks = max; in max_write_same_blocks_store()
579 sd_config_write_same(sdkp); in max_write_same_blocks_store()
588 struct scsi_disk *sdkp = to_scsi_disk(dev); in zoned_cap_show() local
590 if (sdkp->device->type == TYPE_ZBC) in zoned_cap_show()
592 if (sdkp->zoned == 1) in zoned_cap_show()
594 if (sdkp->zoned == 2) in zoned_cap_show()
604 struct scsi_disk *sdkp = to_scsi_disk(dev); in max_retries_store() local
605 struct scsi_device *sdev = sdkp->device; in max_retries_store()
613 sdkp->max_retries = retries; in max_retries_store()
626 struct scsi_disk *sdkp = to_scsi_disk(dev); in max_retries_show() local
628 return sprintf(buf, "%d\n", sdkp->max_retries); in max_retries_show()
702 struct scsi_disk *sdkp = data; in sd_sec_submit() local
703 struct scsi_device *sdev = sdkp->device; in sd_sec_submit()
716 buffer, len, SD_TIMEOUT, sdkp->max_retries, in sd_sec_submit()
823 static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode) in sd_config_discard() argument
825 struct request_queue *q = sdkp->disk->queue; in sd_config_discard()
826 unsigned int logical_block_size = sdkp->device->sector_size; in sd_config_discard()
830 sdkp->unmap_alignment * logical_block_size; in sd_config_discard()
832 max(sdkp->physical_block_size, in sd_config_discard()
833 sdkp->unmap_granularity * logical_block_size); in sd_config_discard()
834 sdkp->provisioning_mode = mode; in sd_config_discard()
844 max_blocks = min_not_zero(sdkp->max_unmap_blocks, in sd_config_discard()
849 if (sdkp->device->unmap_limit_for_ws) in sd_config_discard()
850 max_blocks = sdkp->max_unmap_blocks; in sd_config_discard()
852 max_blocks = sdkp->max_ws_blocks; in sd_config_discard()
858 if (sdkp->device->unmap_limit_for_ws) in sd_config_discard()
859 max_blocks = sdkp->max_unmap_blocks; in sd_config_discard()
861 max_blocks = sdkp->max_ws_blocks; in sd_config_discard()
867 max_blocks = min_not_zero(sdkp->max_ws_blocks, in sd_config_discard()
892 struct scsi_disk *sdkp = scsi_disk(rq->q->disk); in sd_setup_unmap_cmnd() local
911 cmd->allowed = sdkp->max_retries; in sd_setup_unmap_cmnd()
923 struct scsi_disk *sdkp = scsi_disk(rq->q->disk); in sd_setup_write_same16_cmnd() local
938 cmd->allowed = sdkp->max_retries; in sd_setup_write_same16_cmnd()
950 struct scsi_disk *sdkp = scsi_disk(rq->q->disk); in sd_setup_write_same10_cmnd() local
965 cmd->allowed = sdkp->max_retries; in sd_setup_write_same10_cmnd()
976 struct scsi_disk *sdkp = scsi_disk(rq->q->disk); in sd_setup_write_zeroes_cmnd() local
981 switch (sdkp->zeroing_mode) { in sd_setup_write_zeroes_cmnd()
994 if (sdkp->ws16 || lba > 0xffffffff || nr_blocks > 0xffff) in sd_setup_write_zeroes_cmnd()
1000 static void sd_config_write_same(struct scsi_disk *sdkp) in sd_config_write_same() argument
1002 struct request_queue *q = sdkp->disk->queue; in sd_config_write_same()
1003 unsigned int logical_block_size = sdkp->device->sector_size; in sd_config_write_same()
1005 if (sdkp->device->no_write_same) { in sd_config_write_same()
1006 sdkp->max_ws_blocks = 0; in sd_config_write_same()
1015 if (sdkp->max_ws_blocks > SD_MAX_WS10_BLOCKS) in sd_config_write_same()
1016 sdkp->max_ws_blocks = min_not_zero(sdkp->max_ws_blocks, in sd_config_write_same()
1018 else if (sdkp->ws16 || sdkp->ws10 || sdkp->device->no_report_opcodes) in sd_config_write_same()
1019 sdkp->max_ws_blocks = min_not_zero(sdkp->max_ws_blocks, in sd_config_write_same()
1022 sdkp->device->no_write_same = 1; in sd_config_write_same()
1023 sdkp->max_ws_blocks = 0; in sd_config_write_same()
1026 if (sdkp->lbprz && sdkp->lbpws) in sd_config_write_same()
1027 sdkp->zeroing_mode = SD_ZERO_WS16_UNMAP; in sd_config_write_same()
1028 else if (sdkp->lbprz && sdkp->lbpws10) in sd_config_write_same()
1029 sdkp->zeroing_mode = SD_ZERO_WS10_UNMAP; in sd_config_write_same()
1030 else if (sdkp->max_ws_blocks) in sd_config_write_same()
1031 sdkp->zeroing_mode = SD_ZERO_WS; in sd_config_write_same()
1033 sdkp->zeroing_mode = SD_ZERO_WRITE; in sd_config_write_same()
1035 if (sdkp->max_ws_blocks && in sd_config_write_same()
1036 sdkp->physical_block_size > logical_block_size) { in sd_config_write_same()
1049 sdkp->max_ws_blocks = in sd_config_write_same()
1050 round_down(sdkp->max_ws_blocks, in sd_config_write_same()
1051 bytes_to_logical(sdkp->device, in sd_config_write_same()
1052 sdkp->physical_block_size)); in sd_config_write_same()
1056 blk_queue_max_write_zeroes_sectors(q, sdkp->max_ws_blocks * in sd_config_write_same()
1063 struct scsi_disk *sdkp = scsi_disk(rq->q->disk); in sd_setup_flush_cmnd() local
1076 cmd->allowed = sdkp->max_retries; in sd_setup_flush_cmnd()
1163 static int sd_cdl_dld(struct scsi_disk *sdkp, struct scsi_cmnd *scmd) in sd_cdl_dld() argument
1165 struct scsi_device *sdp = sdkp->device; in sd_cdl_dld()
1187 struct scsi_disk *sdkp = scsi_disk(rq->q->disk); in sd_setup_read_write_cmnd() local
1223 threshold = sdkp->capacity - SD_LAST_BUGGY_SECTORS; in sd_setup_read_write_cmnd()
1243 dif = scsi_host_dif_capable(cmd->device->host, sdkp->protection_type); in sd_setup_read_write_cmnd()
1244 dld = sd_cdl_dld(sdkp, cmd); in sd_setup_read_write_cmnd()
1251 if (protect && sdkp->protection_type == T10_PI_TYPE2_PROTECTION) { in sd_setup_read_write_cmnd()
1276 cmd->allowed = sdkp->max_retries; in sd_setup_read_write_cmnd()
1351 static bool sd_need_revalidate(struct gendisk *disk, struct scsi_disk *sdkp) in sd_need_revalidate() argument
1353 if (sdkp->device->removable || sdkp->write_prot) { in sd_need_revalidate()
1383 struct scsi_disk *sdkp = scsi_disk(disk); in sd_open() local
1384 struct scsi_device *sdev = sdkp->device; in sd_open()
1390 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_open\n")); in sd_open()
1400 if (sd_need_revalidate(disk, sdkp)) in sd_open()
1407 if (sdev->removable && !sdkp->media_present && in sd_open()
1416 if (sdkp->write_prot && (mode & BLK_OPEN_WRITE)) in sd_open()
1429 if ((atomic_inc_return(&sdkp->openers) == 1) && sdev->removable) { in sd_open()
1455 struct scsi_disk *sdkp = scsi_disk(disk); in sd_release() local
1456 struct scsi_device *sdev = sdkp->device; in sd_release()
1458 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_release\n")); in sd_release()
1460 if (atomic_dec_return(&sdkp->openers) == 0 && sdev->removable) { in sd_release()
1470 struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); in sd_getgeo() local
1471 struct scsi_device *sdp = sdkp->device; in sd_getgeo()
1473 sector_t capacity = logical_to_sectors(sdp, sdkp->capacity); in sd_getgeo()
1511 struct scsi_disk *sdkp = scsi_disk(disk); in sd_ioctl() local
1512 struct scsi_device *sdp = sdkp->device; in sd_ioctl()
1516 SCSI_LOG_IOCTL(1, sd_printk(KERN_INFO, sdkp, "sd_ioctl: disk=%s, " in sd_ioctl()
1534 return sed_ioctl(sdkp->opal_dev, cmd, p); in sd_ioctl()
1538 static void set_media_not_present(struct scsi_disk *sdkp) in set_media_not_present() argument
1540 if (sdkp->media_present) in set_media_not_present()
1541 sdkp->device->changed = 1; in set_media_not_present()
1543 if (sdkp->device->removable) { in set_media_not_present()
1544 sdkp->media_present = 0; in set_media_not_present()
1545 sdkp->capacity = 0; in set_media_not_present()
1549 static int media_not_present(struct scsi_disk *sdkp, in media_not_present() argument
1561 set_media_not_present(sdkp); in media_not_present()
1579 struct scsi_disk *sdkp = disk->private_data; in sd_check_events() local
1584 if (!sdkp) in sd_check_events()
1587 sdp = sdkp->device; in sd_check_events()
1588 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_check_events\n")); in sd_check_events()
1597 set_media_not_present(sdkp); in sd_check_events()
1613 retval = scsi_test_unit_ready(sdp, SD_TIMEOUT, sdkp->max_retries, in sd_check_events()
1618 set_media_not_present(sdkp); in sd_check_events()
1622 if (media_not_present(sdkp, &sshdr)) in sd_check_events()
1630 if (!sdkp->media_present) in sd_check_events()
1632 sdkp->media_present = 1; in sd_check_events()
1645 static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) in sd_sync_cache() argument
1648 struct scsi_device *sdp = sdkp->device; in sd_sync_cache()
1675 timeout, sdkp->max_retries, &exec_args); in sd_sync_cache()
1681 sd_print_result(sdkp, "Synchronize Cache(10) failed", res); in sd_sync_cache()
1688 sd_print_sense_hdr(sdkp, sshdr); in sd_sync_cache()
1718 struct scsi_disk *sdkp = dev_get_drvdata(dev); in sd_rescan() local
1720 sd_revalidate_disk(sdkp->disk); in sd_rescan()
1794 struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); in sd_pr_in_command() local
1795 struct scsi_device *sdev = sdkp->device; in sd_pr_in_command()
1806 SD_TIMEOUT, sdkp->max_retries, &exec_args); in sd_pr_in_command()
1853 struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); in sd_pr_read_reservation() local
1854 struct scsi_device *sdev = sdkp->device; in sd_pr_read_reservation()
1883 struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); in sd_pr_out_command() local
1884 struct scsi_device *sdev = sdkp->device; in sd_pr_out_command()
1903 sizeof(data), SD_TIMEOUT, sdkp->max_retries, in sd_pr_out_command()
1967 struct scsi_disk *sdkp = scsi_disk(disk); in scsi_disk_free_disk() local
1969 put_device(&sdkp->disk_dev); in scsi_disk_free_disk()
2001 struct scsi_disk *sdkp = scsi_disk(scsi_cmd_to_rq(scmd)->q->disk); in sd_eh_reset() local
2004 sdkp->ignore_medium_access_errors = false; in sd_eh_reset()
2021 struct scsi_disk *sdkp = scsi_disk(scsi_cmd_to_rq(scmd)->q->disk); in sd_eh_action() local
2037 if (!sdkp->ignore_medium_access_errors) { in sd_eh_action()
2038 sdkp->medium_access_timed_out++; in sd_eh_action()
2039 sdkp->ignore_medium_access_errors = true; in sd_eh_action()
2047 if (sdkp->medium_access_timed_out >= sdkp->max_medium_access_timeouts) { in sd_eh_action()
2118 struct scsi_disk *sdkp = scsi_disk(req->q->disk); in sd_done() local
2146 sd_printk(KERN_INFO, sdkp, in sd_done()
2161 sdkp->medium_access_timed_out = 0; in sd_done()
2196 sd_config_discard(sdkp, SD_LBP_DISABLE); in sd_done()
2201 sd_config_discard(sdkp, SD_LBP_DISABLE); in sd_done()
2203 sdkp->device->no_write_same = 1; in sd_done()
2204 sd_config_write_same(sdkp); in sd_done()
2216 if (sd_is_zoned(sdkp)) in sd_done()
2230 sd_spinup_disk(struct scsi_disk *sdkp) in sd_spinup_disk() argument
2250 bool media_was_present = sdkp->media_present; in sd_spinup_disk()
2255 the_result = scsi_execute_cmd(sdkp->device, cmd, in sd_spinup_disk()
2258 sdkp->max_retries, in sd_spinup_disk()
2266 if (media_not_present(sdkp, &sshdr)) { in sd_spinup_disk()
2268 sd_printk(KERN_NOTICE, sdkp, "Media removed, stopped polling\n"); in sd_spinup_disk()
2284 sd_print_result(sdkp, "Test Unit Ready failed", in sd_spinup_disk()
2293 if (sdkp->device->no_start_on_add) in sd_spinup_disk()
2309 sd_printk(KERN_NOTICE, sdkp, "Spinning up disk..."); in sd_spinup_disk()
2314 if (sdkp->device->start_stop_pwr_cond) in sd_spinup_disk()
2316 scsi_execute_cmd(sdkp->device, cmd, in sd_spinup_disk()
2318 SD_TIMEOUT, sdkp->max_retries, in sd_spinup_disk()
2345 sd_printk(KERN_NOTICE, sdkp, "Unit Not Ready\n"); in sd_spinup_disk()
2346 sd_print_sense_hdr(sdkp, &sshdr); in sd_spinup_disk()
2364 static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer) in sd_read_protection_type() argument
2366 struct scsi_device *sdp = sdkp->device; in sd_read_protection_type()
2370 sdkp->protection_type = 0; in sd_read_protection_type()
2377 sd_printk(KERN_ERR, sdkp, "formatted with unsupported" \ in sd_read_protection_type()
2380 sdkp->protection_type = 0; in sd_read_protection_type()
2384 sdkp->protection_type = type; in sd_read_protection_type()
2389 static void sd_config_protection(struct scsi_disk *sdkp) in sd_config_protection() argument
2391 struct scsi_device *sdp = sdkp->device; in sd_config_protection()
2393 sd_dif_config_host(sdkp); in sd_config_protection()
2395 if (!sdkp->protection_type) in sd_config_protection()
2398 if (!scsi_host_dif_capable(sdp->host, sdkp->protection_type)) { in sd_config_protection()
2399 sd_first_printk(KERN_NOTICE, sdkp, in sd_config_protection()
2401 sdkp->protection_type); in sd_config_protection()
2402 sdkp->protection_type = 0; in sd_config_protection()
2405 sd_first_printk(KERN_NOTICE, sdkp, "Enabling DIF Type %u protection\n", in sd_config_protection()
2406 sdkp->protection_type); in sd_config_protection()
2409 static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp, in read_capacity_error() argument
2414 sd_print_sense_hdr(sdkp, sshdr); in read_capacity_error()
2416 sd_printk(KERN_NOTICE, sdkp, "Sense not available.\n"); in read_capacity_error()
2424 set_media_not_present(sdkp); in read_capacity_error()
2431 sdkp->capacity = 0; /* unknown mapped to zero - as usual */ in read_capacity_error()
2441 static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, in read_capacity_16() argument
2468 sdkp->max_retries, &exec_args); in read_capacity_16()
2470 if (media_not_present(sdkp, &sshdr)) in read_capacity_16()
2496 sd_print_result(sdkp, "Read Capacity(16) failed", the_result); in read_capacity_16()
2497 read_capacity_error(sdkp, sdp, &sshdr, sense_valid, the_result); in read_capacity_16()
2504 if (sd_read_protection_type(sdkp, buffer) < 0) { in read_capacity_16()
2505 sdkp->capacity = 0; in read_capacity_16()
2510 sdkp->physical_block_size = (1 << (buffer[13] & 0xf)) * sector_size; in read_capacity_16()
2513 sdkp->rc_basis = (buffer[12] >> 4) & 0x3; in read_capacity_16()
2518 if (alignment && sdkp->first_scan) in read_capacity_16()
2519 sd_printk(KERN_NOTICE, sdkp, in read_capacity_16()
2523 sdkp->lbpme = 1; in read_capacity_16()
2526 sdkp->lbprz = 1; in read_capacity_16()
2528 sd_config_discard(sdkp, SD_LBP_WS16); in read_capacity_16()
2531 sdkp->capacity = lba + 1; in read_capacity_16()
2535 static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp, in read_capacity_10() argument
2555 8, SD_TIMEOUT, sdkp->max_retries, in read_capacity_10()
2558 if (media_not_present(sdkp, &sshdr)) in read_capacity_10()
2576 sd_print_result(sdkp, "Read Capacity(10) failed", the_result); in read_capacity_10()
2577 read_capacity_error(sdkp, sdp, &sshdr, sense_valid, the_result); in read_capacity_10()
2588 sdkp->capacity = 0; in read_capacity_10()
2589 sdkp->physical_block_size = sector_size; in read_capacity_10()
2593 sdkp->capacity = lba + 1; in read_capacity_10()
2594 sdkp->physical_block_size = sector_size; in read_capacity_10()
2615 sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer) in sd_read_capacity() argument
2618 struct scsi_device *sdp = sdkp->device; in sd_read_capacity()
2621 sector_size = read_capacity_16(sdkp, sdp, buffer); in sd_read_capacity()
2627 sector_size = read_capacity_10(sdkp, sdp, buffer); in sd_read_capacity()
2631 sector_size = read_capacity_10(sdkp, sdp, buffer); in sd_read_capacity()
2636 if ((sizeof(sdkp->capacity) > 4) && in sd_read_capacity()
2637 (sdkp->capacity > 0xffffffffULL)) { in sd_read_capacity()
2639 sd_printk(KERN_NOTICE, sdkp, "Very big device. " in sd_read_capacity()
2641 sector_size = read_capacity_16(sdkp, sdp, buffer); in sd_read_capacity()
2643 sd_printk(KERN_NOTICE, sdkp, in sd_read_capacity()
2645 sdkp->capacity = 1 + (sector_t) 0xffffffff; in sd_read_capacity()
2665 (sdp->guess_capacity && (sdkp->capacity & 0x01))) { in sd_read_capacity()
2666 sd_printk(KERN_INFO, sdkp, "Adjusting the sector count " in sd_read_capacity()
2668 (unsigned long long) sdkp->capacity); in sd_read_capacity()
2669 --sdkp->capacity; in sd_read_capacity()
2675 sd_printk(KERN_NOTICE, sdkp, "Sector size 0 reported, " in sd_read_capacity()
2683 sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n", in sd_read_capacity()
2691 sdkp->capacity = 0; in sd_read_capacity()
2702 sdkp->physical_block_size); in sd_read_capacity()
2703 sdkp->device->sector_size = sector_size; in sd_read_capacity()
2705 if (sdkp->capacity > 0xffffffff) in sd_read_capacity()
2714 sd_print_capacity(struct scsi_disk *sdkp, in sd_print_capacity() argument
2717 int sector_size = sdkp->device->sector_size; in sd_print_capacity()
2720 if (!sdkp->first_scan && old_capacity == sdkp->capacity) in sd_print_capacity()
2723 string_get_size(sdkp->capacity, sector_size, in sd_print_capacity()
2725 string_get_size(sdkp->capacity, sector_size, in sd_print_capacity()
2728 sd_printk(KERN_NOTICE, sdkp, in sd_print_capacity()
2730 (unsigned long long)sdkp->capacity, in sd_print_capacity()
2733 if (sdkp->physical_block_size != sector_size) in sd_print_capacity()
2734 sd_printk(KERN_NOTICE, sdkp, in sd_print_capacity()
2736 sdkp->physical_block_size); in sd_print_capacity()
2741 sd_do_mode_sense(struct scsi_disk *sdkp, int dbd, int modepage, in sd_do_mode_sense() argument
2749 if (sdkp->device->use_10_for_ms && len < 8) in sd_do_mode_sense()
2752 return scsi_mode_sense(sdkp->device, dbd, modepage, 0, buffer, len, in sd_do_mode_sense()
2753 SD_TIMEOUT, sdkp->max_retries, data, sshdr); in sd_do_mode_sense()
2761 sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer) in sd_read_write_protect_flag() argument
2764 struct scsi_device *sdp = sdkp->device; in sd_read_write_protect_flag()
2766 int old_wp = sdkp->write_prot; in sd_read_write_protect_flag()
2768 set_disk_ro(sdkp->disk, 0); in sd_read_write_protect_flag()
2770 sd_first_printk(KERN_NOTICE, sdkp, "Assuming Write Enabled\n"); in sd_read_write_protect_flag()
2775 res = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 192, &data, NULL); in sd_read_write_protect_flag()
2782 res = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 4, &data, NULL); in sd_read_write_protect_flag()
2791 res = sd_do_mode_sense(sdkp, 0, 0, buffer, 4, &data, NULL); in sd_read_write_protect_flag()
2797 res = sd_do_mode_sense(sdkp, 0, 0x3F, buffer, 255, in sd_read_write_protect_flag()
2802 sd_first_printk(KERN_WARNING, sdkp, in sd_read_write_protect_flag()
2805 sdkp->write_prot = ((data.device_specific & 0x80) != 0); in sd_read_write_protect_flag()
2806 set_disk_ro(sdkp->disk, sdkp->write_prot); in sd_read_write_protect_flag()
2807 if (sdkp->first_scan || old_wp != sdkp->write_prot) { in sd_read_write_protect_flag()
2808 sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n", in sd_read_write_protect_flag()
2809 sdkp->write_prot ? "on" : "off"); in sd_read_write_protect_flag()
2810 sd_printk(KERN_DEBUG, sdkp, "Mode Sense: %4ph\n", buffer); in sd_read_write_protect_flag()
2820 sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) in sd_read_cache_type() argument
2823 struct scsi_device *sdp = sdkp->device; in sd_read_cache_type()
2830 int old_wce = sdkp->WCE; in sd_read_cache_type()
2831 int old_rcd = sdkp->RCD; in sd_read_cache_type()
2832 int old_dpofua = sdkp->DPOFUA; in sd_read_cache_type()
2835 if (sdkp->cache_override) in sd_read_cache_type()
2859 res = sd_do_mode_sense(sdkp, dbd, modepage, buffer, first_len, in sd_read_cache_type()
2868 sd_first_printk(KERN_ERR, sdkp, in sd_read_cache_type()
2882 sd_first_printk(KERN_NOTICE, sdkp, "Truncating mode parameter " in sd_read_cache_type()
2891 res = sd_do_mode_sense(sdkp, dbd, modepage, buffer, len, in sd_read_cache_type()
2905 sd_first_printk(KERN_ERR, sdkp, in sd_read_cache_type()
2921 sd_first_printk(KERN_ERR, sdkp, in sd_read_cache_type()
2929 sd_first_printk(KERN_WARNING, sdkp, in sd_read_cache_type()
2935 sdkp->WCE = ((buffer[offset + 2] & 0x04) != 0); in sd_read_cache_type()
2936 sdkp->RCD = ((buffer[offset + 2] & 0x01) != 0); in sd_read_cache_type()
2938 sdkp->WCE = ((buffer[offset + 2] & 0x01) == 0); in sd_read_cache_type()
2939 sdkp->RCD = 0; in sd_read_cache_type()
2942 sdkp->DPOFUA = (data.device_specific & 0x10) != 0; in sd_read_cache_type()
2944 sd_first_printk(KERN_NOTICE, sdkp, "Disabling FUA\n"); in sd_read_cache_type()
2945 sdkp->DPOFUA = 0; in sd_read_cache_type()
2946 } else if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw && in sd_read_cache_type()
2947 !sdkp->device->use_16_for_rw) { in sd_read_cache_type()
2948 sd_first_printk(KERN_NOTICE, sdkp, in sd_read_cache_type()
2950 sdkp->DPOFUA = 0; in sd_read_cache_type()
2954 if (sdkp->WCE && sdkp->write_prot) in sd_read_cache_type()
2955 sdkp->WCE = 0; in sd_read_cache_type()
2957 if (sdkp->first_scan || old_wce != sdkp->WCE || in sd_read_cache_type()
2958 old_rcd != sdkp->RCD || old_dpofua != sdkp->DPOFUA) in sd_read_cache_type()
2959 sd_printk(KERN_NOTICE, sdkp, in sd_read_cache_type()
2961 sdkp->WCE ? "enabled" : "disabled", in sd_read_cache_type()
2962 sdkp->RCD ? "disabled" : "enabled", in sd_read_cache_type()
2963 sdkp->DPOFUA ? "supports DPO and FUA" in sd_read_cache_type()
2974 sd_first_printk(KERN_NOTICE, sdkp, "Cache data unavailable\n"); in sd_read_cache_type()
2976 sd_first_printk(KERN_ERR, sdkp, in sd_read_cache_type()
2981 sd_first_printk(KERN_NOTICE, sdkp, in sd_read_cache_type()
2983 sdkp->WCE = 1; in sd_read_cache_type()
2985 sd_first_printk(KERN_WARNING, sdkp, in sd_read_cache_type()
2987 sdkp->WCE = 0; in sd_read_cache_type()
2989 sdkp->RCD = 0; in sd_read_cache_type()
2990 sdkp->DPOFUA = 0; in sd_read_cache_type()
2997 static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer) in sd_read_app_tag_own() argument
3000 struct scsi_device *sdp = sdkp->device; in sd_read_app_tag_own()
3007 if (sdkp->protection_type == 0) in sd_read_app_tag_own()
3011 sdkp->max_retries, &data, &sshdr); in sd_read_app_tag_own()
3015 sd_first_printk(KERN_WARNING, sdkp, in sd_read_app_tag_own()
3019 sd_print_sense_hdr(sdkp, &sshdr); in sd_read_app_tag_own()
3027 sd_first_printk(KERN_ERR, sdkp, "ATO Got wrong page\n"); in sd_read_app_tag_own()
3034 sdkp->ATO = 1; in sd_read_app_tag_own()
3043 static void sd_read_block_limits(struct scsi_disk *sdkp) in sd_read_block_limits() argument
3049 vpd = rcu_dereference(sdkp->device->vpd_pgb0); in sd_read_block_limits()
3053 sdkp->min_xfer_blocks = get_unaligned_be16(&vpd->data[6]); in sd_read_block_limits()
3054 sdkp->max_xfer_blocks = get_unaligned_be32(&vpd->data[8]); in sd_read_block_limits()
3055 sdkp->opt_xfer_blocks = get_unaligned_be32(&vpd->data[12]); in sd_read_block_limits()
3060 sdkp->max_ws_blocks = (u32)get_unaligned_be64(&vpd->data[36]); in sd_read_block_limits()
3062 if (!sdkp->lbpme) in sd_read_block_limits()
3069 sdkp->max_unmap_blocks = lba_count; in sd_read_block_limits()
3071 sdkp->unmap_granularity = get_unaligned_be32(&vpd->data[28]); in sd_read_block_limits()
3074 sdkp->unmap_alignment = in sd_read_block_limits()
3077 if (!sdkp->lbpvpd) { /* LBP VPD page not provided */ in sd_read_block_limits()
3079 if (sdkp->max_unmap_blocks) in sd_read_block_limits()
3080 sd_config_discard(sdkp, SD_LBP_UNMAP); in sd_read_block_limits()
3082 sd_config_discard(sdkp, SD_LBP_WS16); in sd_read_block_limits()
3085 if (sdkp->lbpu && sdkp->max_unmap_blocks) in sd_read_block_limits()
3086 sd_config_discard(sdkp, SD_LBP_UNMAP); in sd_read_block_limits()
3087 else if (sdkp->lbpws) in sd_read_block_limits()
3088 sd_config_discard(sdkp, SD_LBP_WS16); in sd_read_block_limits()
3089 else if (sdkp->lbpws10) in sd_read_block_limits()
3090 sd_config_discard(sdkp, SD_LBP_WS10); in sd_read_block_limits()
3092 sd_config_discard(sdkp, SD_LBP_DISABLE); in sd_read_block_limits()
3104 static void sd_read_block_characteristics(struct scsi_disk *sdkp) in sd_read_block_characteristics() argument
3106 struct request_queue *q = sdkp->disk->queue; in sd_read_block_characteristics()
3112 vpd = rcu_dereference(sdkp->device->vpd_pgb1); in sd_read_block_characteristics()
3128 if (sdkp->device->type == TYPE_ZBC) { in sd_read_block_characteristics()
3134 disk_set_zoned(sdkp->disk, BLK_ZONED_HM); in sd_read_block_characteristics()
3135 blk_queue_zone_write_granularity(q, sdkp->physical_block_size); in sd_read_block_characteristics()
3137 sdkp->zoned = zoned; in sd_read_block_characteristics()
3138 if (sdkp->zoned == 1) { in sd_read_block_characteristics()
3140 disk_set_zoned(sdkp->disk, BLK_ZONED_HA); in sd_read_block_characteristics()
3143 disk_set_zoned(sdkp->disk, BLK_ZONED_NONE); in sd_read_block_characteristics()
3147 if (!sdkp->first_scan) in sd_read_block_characteristics()
3151 sd_printk(KERN_NOTICE, sdkp, "Host-%s zoned block device\n", in sd_read_block_characteristics()
3154 if (sdkp->zoned == 1) in sd_read_block_characteristics()
3155 sd_printk(KERN_NOTICE, sdkp, in sd_read_block_characteristics()
3157 else if (sdkp->zoned == 2) in sd_read_block_characteristics()
3158 sd_printk(KERN_NOTICE, sdkp, in sd_read_block_characteristics()
3167 static void sd_read_block_provisioning(struct scsi_disk *sdkp) in sd_read_block_provisioning() argument
3171 if (sdkp->lbpme == 0) in sd_read_block_provisioning()
3175 vpd = rcu_dereference(sdkp->device->vpd_pgb2); in sd_read_block_provisioning()
3182 sdkp->lbpvpd = 1; in sd_read_block_provisioning()
3183 sdkp->lbpu = (vpd->data[5] >> 7) & 1; /* UNMAP */ in sd_read_block_provisioning()
3184 sdkp->lbpws = (vpd->data[5] >> 6) & 1; /* WRITE SAME(16) w/ UNMAP */ in sd_read_block_provisioning()
3185 sdkp->lbpws10 = (vpd->data[5] >> 5) & 1; /* WRITE SAME(10) w/ UNMAP */ in sd_read_block_provisioning()
3189 static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer) in sd_read_write_same() argument
3191 struct scsi_device *sdev = sdkp->device; in sd_read_write_same()
3216 sdkp->ws16 = 1; in sd_read_write_same()
3219 sdkp->ws10 = 1; in sd_read_write_same()
3222 static void sd_read_security(struct scsi_disk *sdkp, unsigned char *buffer) in sd_read_security() argument
3224 struct scsi_device *sdev = sdkp->device; in sd_read_security()
3233 sdkp->security = 1; in sd_read_security()
3236 static inline sector_t sd64_to_sectors(struct scsi_disk *sdkp, u8 *buf) in sd64_to_sectors() argument
3238 return logical_to_sectors(sdkp->device, get_unaligned_be64(buf)); in sd64_to_sectors()
3245 static void sd_read_cpr(struct scsi_disk *sdkp) in sd_read_cpr() argument
3257 if (sdkp->first_scan) in sd_read_cpr()
3260 if (!sdkp->capacity) in sd_read_cpr()
3269 if (!buffer || scsi_get_vpd_page(sdkp->device, 0xb9, buffer, buf_len)) in sd_read_cpr()
3275 sd_printk(KERN_ERR, sdkp, in sd_read_cpr()
3286 iars = disk_alloc_independent_access_ranges(sdkp->disk, nr_cpr); in sd_read_cpr()
3295 sd_printk(KERN_ERR, sdkp, in sd_read_cpr()
3301 iars->ia_range[i].sector = sd64_to_sectors(sdkp, desc + 8); in sd_read_cpr()
3302 iars->ia_range[i].nr_sectors = sd64_to_sectors(sdkp, desc + 16); in sd_read_cpr()
3306 disk_set_independent_access_ranges(sdkp->disk, iars); in sd_read_cpr()
3307 if (nr_cpr && sdkp->nr_actuators != nr_cpr) { in sd_read_cpr()
3308 sd_printk(KERN_NOTICE, sdkp, in sd_read_cpr()
3310 sdkp->nr_actuators = nr_cpr; in sd_read_cpr()
3316 static bool sd_validate_min_xfer_size(struct scsi_disk *sdkp) in sd_validate_min_xfer_size() argument
3318 struct scsi_device *sdp = sdkp->device; in sd_validate_min_xfer_size()
3320 logical_to_bytes(sdp, sdkp->min_xfer_blocks); in sd_validate_min_xfer_size()
3322 if (sdkp->min_xfer_blocks == 0) in sd_validate_min_xfer_size()
3325 if (min_xfer_bytes & (sdkp->physical_block_size - 1)) { in sd_validate_min_xfer_size()
3326 sd_first_printk(KERN_WARNING, sdkp, in sd_validate_min_xfer_size()
3329 min_xfer_bytes, sdkp->physical_block_size); in sd_validate_min_xfer_size()
3330 sdkp->min_xfer_blocks = 0; in sd_validate_min_xfer_size()
3334 sd_first_printk(KERN_INFO, sdkp, "Preferred minimum I/O size %u bytes\n", in sd_validate_min_xfer_size()
3344 static bool sd_validate_opt_xfer_size(struct scsi_disk *sdkp, in sd_validate_opt_xfer_size() argument
3347 struct scsi_device *sdp = sdkp->device; in sd_validate_opt_xfer_size()
3349 logical_to_bytes(sdp, sdkp->opt_xfer_blocks); in sd_validate_opt_xfer_size()
3351 logical_to_bytes(sdp, sdkp->min_xfer_blocks); in sd_validate_opt_xfer_size()
3353 if (sdkp->opt_xfer_blocks == 0) in sd_validate_opt_xfer_size()
3356 if (sdkp->opt_xfer_blocks > dev_max) { in sd_validate_opt_xfer_size()
3357 sd_first_printk(KERN_WARNING, sdkp, in sd_validate_opt_xfer_size()
3360 sdkp->opt_xfer_blocks, dev_max); in sd_validate_opt_xfer_size()
3364 if (sdkp->opt_xfer_blocks > SD_DEF_XFER_BLOCKS) { in sd_validate_opt_xfer_size()
3365 sd_first_printk(KERN_WARNING, sdkp, in sd_validate_opt_xfer_size()
3368 sdkp->opt_xfer_blocks, SD_DEF_XFER_BLOCKS); in sd_validate_opt_xfer_size()
3373 sd_first_printk(KERN_WARNING, sdkp, in sd_validate_opt_xfer_size()
3381 sd_first_printk(KERN_WARNING, sdkp, in sd_validate_opt_xfer_size()
3389 if (opt_xfer_bytes & (sdkp->physical_block_size - 1)) { in sd_validate_opt_xfer_size()
3390 sd_first_printk(KERN_WARNING, sdkp, in sd_validate_opt_xfer_size()
3393 opt_xfer_bytes, sdkp->physical_block_size); in sd_validate_opt_xfer_size()
3397 sd_first_printk(KERN_INFO, sdkp, "Optimal transfer size %u bytes\n", in sd_validate_opt_xfer_size()
3409 struct scsi_disk *sdkp = scsi_disk(disk); in sd_revalidate_disk() local
3410 struct scsi_device *sdp = sdkp->device; in sd_revalidate_disk()
3411 struct request_queue *q = sdkp->disk->queue; in sd_revalidate_disk()
3412 sector_t old_capacity = sdkp->capacity; in sd_revalidate_disk()
3416 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, in sd_revalidate_disk()
3428 sd_printk(KERN_WARNING, sdkp, "sd_revalidate_disk: Memory " in sd_revalidate_disk()
3433 sd_spinup_disk(sdkp); in sd_revalidate_disk()
3439 if (sdkp->media_present) { in sd_revalidate_disk()
3440 sd_read_capacity(sdkp, buffer); in sd_revalidate_disk()
3452 sd_read_block_provisioning(sdkp); in sd_revalidate_disk()
3453 sd_read_block_limits(sdkp); in sd_revalidate_disk()
3454 sd_read_block_characteristics(sdkp); in sd_revalidate_disk()
3455 sd_zbc_read_zones(sdkp, buffer); in sd_revalidate_disk()
3456 sd_read_cpr(sdkp); in sd_revalidate_disk()
3459 sd_print_capacity(sdkp, old_capacity); in sd_revalidate_disk()
3461 sd_read_write_protect_flag(sdkp, buffer); in sd_revalidate_disk()
3462 sd_read_cache_type(sdkp, buffer); in sd_revalidate_disk()
3463 sd_read_app_tag_own(sdkp, buffer); in sd_revalidate_disk()
3464 sd_read_write_same(sdkp, buffer); in sd_revalidate_disk()
3465 sd_read_security(sdkp, buffer); in sd_revalidate_disk()
3466 sd_config_protection(sdkp); in sd_revalidate_disk()
3473 sd_set_flush_flag(sdkp); in sd_revalidate_disk()
3479 dev_max = min_not_zero(dev_max, sdkp->max_xfer_blocks); in sd_revalidate_disk()
3482 if (sd_validate_min_xfer_size(sdkp)) in sd_revalidate_disk()
3483 blk_queue_io_min(sdkp->disk->queue, in sd_revalidate_disk()
3484 logical_to_bytes(sdp, sdkp->min_xfer_blocks)); in sd_revalidate_disk()
3486 blk_queue_io_min(sdkp->disk->queue, 0); in sd_revalidate_disk()
3488 if (sd_validate_opt_xfer_size(sdkp, dev_max)) { in sd_revalidate_disk()
3489 q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks); in sd_revalidate_disk()
3490 rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks); in sd_revalidate_disk()
3511 if (sdkp->first_scan || in sd_revalidate_disk()
3516 sdkp->first_scan = 0; in sd_revalidate_disk()
3518 set_capacity_and_notify(disk, logical_to_sectors(sdp, sdkp->capacity)); in sd_revalidate_disk()
3519 sd_config_write_same(sdkp); in sd_revalidate_disk()
3527 if (sd_zbc_revalidate_zones(sdkp)) in sd_revalidate_disk()
3621 struct scsi_disk *sdkp; in sd_probe() local
3644 sdkp = kzalloc(sizeof(*sdkp), GFP_KERNEL); in sd_probe()
3645 if (!sdkp) in sd_probe()
3665 sdkp->device = sdp; in sd_probe()
3666 sdkp->disk = gd; in sd_probe()
3667 sdkp->index = index; in sd_probe()
3668 sdkp->max_retries = SD_MAX_RETRIES; in sd_probe()
3669 atomic_set(&sdkp->openers, 0); in sd_probe()
3670 atomic_set(&sdkp->device->ioerr_cnt, 0); in sd_probe()
3680 device_initialize(&sdkp->disk_dev); in sd_probe()
3681 sdkp->disk_dev.parent = get_device(dev); in sd_probe()
3682 sdkp->disk_dev.class = &sd_disk_class; in sd_probe()
3683 dev_set_name(&sdkp->disk_dev, "%s", dev_name(dev)); in sd_probe()
3685 error = device_add(&sdkp->disk_dev); in sd_probe()
3687 put_device(&sdkp->disk_dev); in sd_probe()
3691 dev_set_drvdata(dev, sdkp); in sd_probe()
3698 gd->private_data = sdkp; in sd_probe()
3702 sdkp->capacity = 0; in sd_probe()
3703 sdkp->media_present = 1; in sd_probe()
3704 sdkp->write_prot = 0; in sd_probe()
3705 sdkp->cache_override = 0; in sd_probe()
3706 sdkp->WCE = 0; in sd_probe()
3707 sdkp->RCD = 0; in sd_probe()
3708 sdkp->ATO = 0; in sd_probe()
3709 sdkp->first_scan = 1; in sd_probe()
3710 sdkp->max_medium_access_timeouts = SD_MAX_MEDIUM_TIMEOUTS; in sd_probe()
3728 put_device(&sdkp->disk_dev); in sd_probe()
3733 if (sdkp->security) { in sd_probe()
3734 sdkp->opal_dev = init_opal_dev(sdkp, &sd_sec_submit); in sd_probe()
3735 if (sdkp->opal_dev) in sd_probe()
3736 sd_printk(KERN_NOTICE, sdkp, "supports TCG Opal\n"); in sd_probe()
3739 sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", in sd_probe()
3750 kfree(sdkp); in sd_probe()
3769 struct scsi_disk *sdkp = dev_get_drvdata(dev); in sd_remove() local
3771 scsi_autopm_get_device(sdkp->device); in sd_remove()
3773 device_del(&sdkp->disk_dev); in sd_remove()
3774 del_gendisk(sdkp->disk); in sd_remove()
3775 if (!sdkp->suspended) in sd_remove()
3778 put_disk(sdkp->disk); in sd_remove()
3784 struct scsi_disk *sdkp = to_scsi_disk(dev); in scsi_disk_release() local
3786 ida_free(&sd_index_ida, sdkp->index); in scsi_disk_release()
3787 sd_zbc_free_zone_info(sdkp); in scsi_disk_release()
3788 put_device(&sdkp->device->sdev_gendev); in scsi_disk_release()
3789 free_opal_dev(sdkp->opal_dev); in scsi_disk_release()
3791 kfree(sdkp); in scsi_disk_release()
3794 static int sd_start_stop_device(struct scsi_disk *sdkp, int start) in sd_start_stop_device() argument
3802 struct scsi_device *sdp = sdkp->device; in sd_start_stop_device()
3815 sdkp->max_retries, &exec_args); in sd_start_stop_device()
3817 sd_print_result(sdkp, "Start/Stop Unit failed", res); in sd_start_stop_device()
3819 sd_print_sense_hdr(sdkp, &sshdr); in sd_start_stop_device()
3840 struct scsi_disk *sdkp = dev_get_drvdata(dev); in sd_shutdown() local
3842 if (!sdkp) in sd_shutdown()
3848 if (sdkp->WCE && sdkp->media_present) { in sd_shutdown()
3849 sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); in sd_shutdown()
3850 sd_sync_cache(sdkp, NULL); in sd_shutdown()
3854 sdkp->device->manage_system_start_stop) || in sd_shutdown()
3856 sdkp->device->manage_shutdown)) { in sd_shutdown()
3857 sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); in sd_shutdown()
3858 sd_start_stop_device(sdkp, 0); in sd_shutdown()
3870 struct scsi_disk *sdkp = dev_get_drvdata(dev); in sd_suspend_common() local
3874 if (!sdkp) /* E.g.: runtime suspend following sd_remove() */ in sd_suspend_common()
3877 if (sdkp->WCE && sdkp->media_present) { in sd_suspend_common()
3878 if (!sdkp->device->silence_suspend) in sd_suspend_common()
3879 sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); in sd_suspend_common()
3880 ret = sd_sync_cache(sdkp, &sshdr); in sd_suspend_common()
3900 if (sd_do_start_stop(sdkp->device, runtime)) { in sd_suspend_common()
3901 if (!sdkp->device->silence_suspend) in sd_suspend_common()
3902 sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); in sd_suspend_common()
3904 ret = sd_start_stop_device(sdkp, 0); in sd_suspend_common()
3910 sdkp->suspended = true; in sd_suspend_common()
3930 struct scsi_disk *sdkp = dev_get_drvdata(dev); in sd_resume() local
3933 if (!sdkp) /* E.g.: runtime resume at the start of sd_probe() */ in sd_resume()
3936 if (!sd_do_start_stop(sdkp->device, runtime)) { in sd_resume()
3937 sdkp->suspended = false; in sd_resume()
3941 if (!sdkp->device->no_start_on_resume) { in sd_resume()
3942 sd_printk(KERN_NOTICE, sdkp, "Starting disk\n"); in sd_resume()
3943 ret = sd_start_stop_device(sdkp, 1); in sd_resume()
3947 opal_unlock_from_suspend(sdkp->opal_dev); in sd_resume()
3948 sdkp->suspended = false; in sd_resume()
3964 struct scsi_disk *sdkp = dev_get_drvdata(dev); in sd_resume_runtime() local
3967 if (!sdkp) /* E.g.: runtime resume at the start of sd_probe() */ in sd_resume_runtime()
3970 sdp = sdkp->device; in sd_resume_runtime()
3982 sd_printk(KERN_NOTICE, sdkp, in sd_resume_runtime()
4087 void sd_print_sense_hdr(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) in sd_print_sense_hdr() argument
4089 scsi_print_sense_hdr(sdkp->device, in sd_print_sense_hdr()
4090 sdkp->disk ? sdkp->disk->disk_name : NULL, sshdr); in sd_print_sense_hdr()
4093 void sd_print_result(const struct scsi_disk *sdkp, const char *msg, int result) in sd_print_result() argument
4098 sd_printk(KERN_INFO, sdkp, in sd_print_result()
4103 sd_printk(KERN_INFO, sdkp, in sd_print_result()