H A D | sd.c | 117 static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer); 138 static void sd_set_flush_flag(struct scsi_disk *sdkp) sd_set_flush_flag() argument 142 if (sdkp->WCE) { sd_set_flush_flag() 144 if (sdkp->DPOFUA) sd_set_flush_flag() 148 blk_queue_flush(sdkp->disk->queue, flush); sd_set_flush_flag() 156 struct scsi_disk *sdkp = to_scsi_disk(dev); cache_type_store() local 157 struct scsi_device *sdp = sdkp->device; cache_type_store() 173 sdkp->cache_override = 1; cache_type_store() 175 sdkp->cache_override = 0; cache_type_store() 189 wce = (ct & 0x02) && !sdkp->write_prot ? 1 : 0; cache_type_store() 191 if (sdkp->cache_override) { cache_type_store() 192 sdkp->WCE = wce; cache_type_store() 193 sdkp->RCD = rcd; cache_type_store() 194 sd_set_flush_flag(sdkp); cache_type_store() 213 sd_print_sense_hdr(sdkp, &sshdr); cache_type_store() 216 revalidate_disk(sdkp->disk); cache_type_store() 224 struct scsi_disk *sdkp = to_scsi_disk(dev); manage_start_stop_show() local 225 struct scsi_device *sdp = sdkp->device; manage_start_stop_show() 234 struct scsi_disk *sdkp = to_scsi_disk(dev); manage_start_stop_store() local 235 struct scsi_device *sdp = sdkp->device; manage_start_stop_store() 249 struct scsi_disk *sdkp = to_scsi_disk(dev); allow_restart_show() local 251 return snprintf(buf, 40, "%d\n", sdkp->device->allow_restart); allow_restart_show() 258 struct scsi_disk *sdkp = to_scsi_disk(dev); allow_restart_store() local 259 struct scsi_device *sdp = sdkp->device; allow_restart_store() 276 struct scsi_disk *sdkp = to_scsi_disk(dev); cache_type_show() local 277 int ct = sdkp->RCD + 2*sdkp->WCE; cache_type_show() 286 struct scsi_disk *sdkp = to_scsi_disk(dev); FUA_show() local 288 return snprintf(buf, 20, "%u\n", sdkp->DPOFUA); FUA_show() 296 struct scsi_disk *sdkp = to_scsi_disk(dev); protection_type_show() local 298 return snprintf(buf, 20, "%u\n", sdkp->protection_type); protection_type_show() 305 struct scsi_disk *sdkp = to_scsi_disk(dev); protection_type_store() local 318 sdkp->protection_type = val; protection_type_store() 328 struct scsi_disk *sdkp = to_scsi_disk(dev); protection_mode_show() local 329 struct scsi_device *sdp = sdkp->device; protection_mode_show() 332 dif = scsi_host_dif_capable(sdp->host, sdkp->protection_type); protection_mode_show() 333 dix = scsi_host_dix_capable(sdp->host, sdkp->protection_type); protection_mode_show() 350 struct scsi_disk *sdkp = to_scsi_disk(dev); app_tag_own_show() local 352 return snprintf(buf, 20, "%u\n", sdkp->ATO); app_tag_own_show() 360 struct scsi_disk *sdkp = to_scsi_disk(dev); thin_provisioning_show() local 362 return snprintf(buf, 20, "%u\n", sdkp->lbpme); thin_provisioning_show() 379 struct scsi_disk *sdkp = to_scsi_disk(dev); provisioning_mode_show() local 381 return snprintf(buf, 20, "%s\n", lbp_mode[sdkp->provisioning_mode]); provisioning_mode_show() 388 struct scsi_disk *sdkp = to_scsi_disk(dev); provisioning_mode_store() local 389 struct scsi_device *sdp = sdkp->device; provisioning_mode_store() 398 sd_config_discard(sdkp, SD_LBP_UNMAP); provisioning_mode_store() 400 sd_config_discard(sdkp, SD_LBP_WS16); provisioning_mode_store() 402 sd_config_discard(sdkp, SD_LBP_WS10); provisioning_mode_store() 404 sd_config_discard(sdkp, SD_LBP_ZERO); provisioning_mode_store() 406 sd_config_discard(sdkp, SD_LBP_DISABLE); provisioning_mode_store() 418 struct scsi_disk *sdkp = to_scsi_disk(dev); max_medium_access_timeouts_show() local 420 return snprintf(buf, 20, "%u\n", sdkp->max_medium_access_timeouts); max_medium_access_timeouts_show() 428 struct scsi_disk *sdkp = to_scsi_disk(dev); max_medium_access_timeouts_store() local 434 err = kstrtouint(buf, 10, &sdkp->max_medium_access_timeouts); max_medium_access_timeouts_store() 444 struct scsi_disk *sdkp = to_scsi_disk(dev); max_write_same_blocks_show() local 446 return snprintf(buf, 20, "%u\n", sdkp->max_ws_blocks); max_write_same_blocks_show() 453 struct scsi_disk *sdkp = to_scsi_disk(dev); max_write_same_blocks_store() local 454 struct scsi_device *sdp = sdkp->device; max_write_same_blocks_store() 473 sdkp->max_ws_blocks = max; max_write_same_blocks_store() 476 sd_config_write_same(sdkp); max_write_same_blocks_store() 571 struct scsi_disk *sdkp = NULL; scsi_disk_get() local 576 sdkp = scsi_disk(disk); scsi_disk_get() 577 if (scsi_device_get(sdkp->device) == 0) scsi_disk_get() 578 get_device(&sdkp->dev); scsi_disk_get() 580 sdkp = NULL; scsi_disk_get() 583 return sdkp; scsi_disk_get() 586 static void scsi_disk_put(struct scsi_disk *sdkp) scsi_disk_put() argument 588 struct scsi_device *sdev = sdkp->device; scsi_disk_put() 591 put_device(&sdkp->dev); scsi_disk_put() 634 static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode) sd_config_discard() argument 636 struct request_queue *q = sdkp->disk->queue; sd_config_discard() 637 unsigned int logical_block_size = sdkp->device->sector_size; sd_config_discard() 649 if (sdkp->lbprz) { sd_config_discard() 653 q->limits.discard_alignment = sdkp->unmap_alignment * sd_config_discard() 656 max(sdkp->physical_block_size, sd_config_discard() 657 sdkp->unmap_granularity * logical_block_size); sd_config_discard() 660 sdkp->provisioning_mode = mode; sd_config_discard() 670 max_blocks = min_not_zero(sdkp->max_unmap_blocks, sd_config_discard() 675 max_blocks = min_not_zero(sdkp->max_ws_blocks, sd_config_discard() 677 q->limits.discard_zeroes_data = sdkp->lbprz; sd_config_discard() 681 max_blocks = min_not_zero(sdkp->max_ws_blocks, sd_config_discard() 683 q->limits.discard_zeroes_data = sdkp->lbprz; sd_config_discard() 687 max_blocks = min_not_zero(sdkp->max_ws_blocks, sd_config_discard() 709 struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); sd_setup_discard_cmnd() local 725 switch (sdkp->provisioning_mode) { sd_setup_discard_cmnd() 748 len = sdkp->device->sector_size; sd_setup_discard_cmnd() 755 if (sdkp->provisioning_mode == SD_LBP_WS10) sd_setup_discard_cmnd() 760 len = sdkp->device->sector_size; sd_setup_discard_cmnd() 792 static void sd_config_write_same(struct scsi_disk *sdkp) sd_config_write_same() argument 794 struct request_queue *q = sdkp->disk->queue; sd_config_write_same() 795 unsigned int logical_block_size = sdkp->device->sector_size; sd_config_write_same() 797 if (sdkp->device->no_write_same) { sd_config_write_same() 798 sdkp->max_ws_blocks = 0; sd_config_write_same() 807 if (sdkp->max_ws_blocks > SD_MAX_WS10_BLOCKS) sd_config_write_same() 808 sdkp->max_ws_blocks = min_not_zero(sdkp->max_ws_blocks, sd_config_write_same() 810 else if (sdkp->ws16 || sdkp->ws10 || sdkp->device->no_report_opcodes) sd_config_write_same() 811 sdkp->max_ws_blocks = min_not_zero(sdkp->max_ws_blocks, sd_config_write_same() 814 sdkp->device->no_write_same = 1; sd_config_write_same() 815 sdkp->max_ws_blocks = 0; sd_config_write_same() 819 blk_queue_max_write_same_sectors(q, sdkp->max_ws_blocks * sd_config_write_same() 834 struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); sd_setup_write_same_cmnd() local 841 if (sdkp->device->no_write_same) sd_setup_write_same_cmnd() 851 if (sdkp->ws16 || sector > 0xffffffff || nr_sectors > 0xffff) { sd_setup_write_same_cmnd() 903 struct scsi_disk *sdkp; sd_setup_read_write_cmnd() local 915 sdkp = scsi_disk(disk); sd_setup_read_write_cmnd() 1026 dif = scsi_host_dif_capable(SCpnt->device->host, sdkp->protection_type); sd_setup_read_write_cmnd() 1033 if (protect && sdkp->protection_type == SD_DIF_TYPE2_PROTECTION) { sd_setup_read_write_cmnd() 1181 struct scsi_disk *sdkp = scsi_disk_get(bdev->bd_disk); sd_open() local 1185 if (!sdkp) sd_open() 1188 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_open\n")); sd_open() 1190 sdev = sdkp->device; sd_open() 1200 if (sdev->removable || sdkp->write_prot) sd_open() 1207 if (sdev->removable && !sdkp->media_present && !(mode & FMODE_NDELAY)) sd_open() 1215 if (sdkp->write_prot && (mode & FMODE_WRITE)) sd_open() 1228 if ((atomic_inc_return(&sdkp->openers) == 1) && sdev->removable) { sd_open() 1236 scsi_disk_put(sdkp); sd_open() 1255 struct scsi_disk *sdkp = scsi_disk(disk); sd_release() local 1256 struct scsi_device *sdev = sdkp->device; sd_release() 1258 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_release\n")); sd_release() 1260 if (atomic_dec_return(&sdkp->openers) == 0 && sdev->removable) { sd_release() 1270 scsi_disk_put(sdkp); sd_release() 1275 struct scsi_disk *sdkp = scsi_disk(bdev->bd_disk); sd_getgeo() local 1276 struct scsi_device *sdp = sdkp->device; sd_getgeo() 1278 sector_t capacity = logical_to_sectors(sdp, sdkp->capacity); sd_getgeo() 1316 struct scsi_disk *sdkp = scsi_disk(disk); sd_ioctl() local 1317 struct scsi_device *sdp = sdkp->device; sd_ioctl() 1321 SCSI_LOG_IOCTL(1, sd_printk(KERN_INFO, sdkp, "sd_ioctl: disk=%s, " sd_ioctl() 1360 static void set_media_not_present(struct scsi_disk *sdkp) set_media_not_present() argument 1362 if (sdkp->media_present) set_media_not_present() 1363 sdkp->device->changed = 1; set_media_not_present() 1365 if (sdkp->device->removable) { set_media_not_present() 1366 sdkp->media_present = 0; set_media_not_present() 1367 sdkp->capacity = 0; set_media_not_present() 1371 static int media_not_present(struct scsi_disk *sdkp, media_not_present() argument 1383 set_media_not_present(sdkp); media_not_present() 1401 struct scsi_disk *sdkp = scsi_disk(disk); sd_check_events() local 1402 struct scsi_device *sdp = sdkp->device; sd_check_events() 1406 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, "sd_check_events\n")); sd_check_events() 1415 set_media_not_present(sdkp); sd_check_events() 1438 set_media_not_present(sdkp); sd_check_events() 1442 if (media_not_present(sdkp, sshdr)) sd_check_events() 1449 if (!sdkp->media_present) sd_check_events() 1451 sdkp->media_present = 1; sd_check_events() 1465 static int sd_sync_cache(struct scsi_disk *sdkp) sd_sync_cache() argument 1468 struct scsi_device *sdp = sdkp->device; sd_sync_cache() 1492 sd_print_result(sdkp, "Synchronize Cache(10) failed", res); sd_sync_cache() 1495 sd_print_sense_hdr(sdkp, &sshdr); sd_sync_cache() 1523 struct scsi_disk *sdkp = dev_get_drvdata(dev); sd_rescan() local 1525 revalidate_disk(sdkp->disk); sd_rescan() 1677 struct scsi_disk *sdkp = scsi_disk(scmd->request->rq_disk); sd_eh_action() local 1692 sdkp->medium_access_timed_out++; sd_eh_action() 1699 if (sdkp->medium_access_timed_out >= sdkp->max_medium_access_timeouts) { sd_eh_action() 1765 struct scsi_disk *sdkp = scsi_disk(SCpnt->request->rq_disk); sd_done() local 1787 sdkp->medium_access_timed_out = 0; sd_done() 1820 sd_config_discard(sdkp, SD_LBP_DISABLE); sd_done() 1825 sd_config_discard(sdkp, SD_LBP_DISABLE); sd_done() 1827 sdkp->device->no_write_same = 1; sd_done() 1828 sd_config_write_same(sdkp); sd_done() 1855 sd_spinup_disk(struct scsi_disk *sdkp) sd_spinup_disk() argument 1875 the_result = scsi_execute_req(sdkp->device, cmd, sd_spinup_disk() 1885 if (media_not_present(sdkp, &sshdr)) sd_spinup_disk() 1900 sd_print_result(sdkp, "Test Unit Ready failed", sd_spinup_disk() 1909 if (sdkp->device->no_start_on_add) sd_spinup_disk() 1923 sd_printk(KERN_NOTICE, sdkp, "Spinning up disk..."); sd_spinup_disk() 1928 if (sdkp->device->start_stop_pwr_cond) sd_spinup_disk() 1930 scsi_execute_req(sdkp->device, cmd, DMA_NONE, sd_spinup_disk() 1959 sd_printk(KERN_NOTICE, sdkp, "Unit Not Ready\n"); sd_spinup_disk() 1960 sd_print_sense_hdr(sdkp, &sshdr); sd_spinup_disk() 1979 static int sd_read_protection_type(struct scsi_disk *sdkp, unsigned char *buffer) sd_read_protection_type() argument 1981 struct scsi_device *sdp = sdkp->device; sd_read_protection_type() 1995 if (sdkp->first_scan || type != sdkp->protection_type) sd_read_protection_type() 1998 sd_printk(KERN_ERR, sdkp, "formatted with unsupported" \ sd_read_protection_type() 2003 sd_printk(KERN_NOTICE, sdkp, sd_read_protection_type() 2007 sd_printk(KERN_NOTICE, sdkp, sd_read_protection_type() 2012 sdkp->protection_type = type; sd_read_protection_type() 2017 static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp, read_capacity_error() argument 2022 sd_print_sense_hdr(sdkp, sshdr); read_capacity_error() 2024 sd_printk(KERN_NOTICE, sdkp, "Sense not available.\n"); read_capacity_error() 2032 set_media_not_present(sdkp); read_capacity_error() 2039 sdkp->capacity = 0; /* unknown mapped to zero - as usual */ read_capacity_error() 2049 static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, read_capacity_16() argument 2075 if (media_not_present(sdkp, &sshdr)) read_capacity_16() 2101 sd_print_result(sdkp, "Read Capacity(16) failed", the_result); read_capacity_16() 2102 read_capacity_error(sdkp, sdp, &sshdr, sense_valid, the_result); read_capacity_16() 2109 if (sd_read_protection_type(sdkp, buffer) < 0) { read_capacity_16() 2110 sdkp->capacity = 0; read_capacity_16() 2114 if ((sizeof(sdkp->capacity) == 4) && (lba >= 0xffffffffULL)) { read_capacity_16() 2115 sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a " read_capacity_16() 2118 sdkp->capacity = 0; read_capacity_16() 2123 sdkp->physical_block_size = (1 << (buffer[13] & 0xf)) * sector_size; read_capacity_16() 2128 if (alignment && sdkp->first_scan) read_capacity_16() 2129 sd_printk(KERN_NOTICE, sdkp, read_capacity_16() 2133 sdkp->lbpme = 1; read_capacity_16() 2136 sdkp->lbprz = 1; read_capacity_16() 2138 sd_config_discard(sdkp, SD_LBP_WS16); read_capacity_16() 2141 sdkp->capacity = lba + 1; read_capacity_16() 2145 static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp, read_capacity_10() argument 2165 if (media_not_present(sdkp, &sshdr)) read_capacity_10() 2183 sd_print_result(sdkp, "Read Capacity(10) failed", the_result); read_capacity_10() 2184 read_capacity_error(sdkp, sdp, &sshdr, sense_valid, the_result); read_capacity_10() 2195 sdkp->capacity = 0; read_capacity_10() 2196 sdkp->physical_block_size = sector_size; read_capacity_10() 2200 if ((sizeof(sdkp->capacity) == 4) && (lba == 0xffffffff)) { read_capacity_10() 2201 sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a " read_capacity_10() 2204 sdkp->capacity = 0; read_capacity_10() 2208 sdkp->capacity = lba + 1; read_capacity_10() 2209 sdkp->physical_block_size = sector_size; read_capacity_10() 2230 sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer) sd_read_capacity() argument 2233 struct scsi_device *sdp = sdkp->device; sd_read_capacity() 2234 sector_t old_capacity = sdkp->capacity; sd_read_capacity() 2237 sector_size = read_capacity_16(sdkp, sdp, buffer); sd_read_capacity() 2243 sector_size = read_capacity_10(sdkp, sdp, buffer); sd_read_capacity() 2247 sector_size = read_capacity_10(sdkp, sdp, buffer); sd_read_capacity() 2252 if ((sizeof(sdkp->capacity) > 4) && sd_read_capacity() 2253 (sdkp->capacity > 0xffffffffULL)) { sd_read_capacity() 2255 sd_printk(KERN_NOTICE, sdkp, "Very big device. " sd_read_capacity() 2257 sector_size = read_capacity_16(sdkp, sdp, buffer); sd_read_capacity() 2259 sd_printk(KERN_NOTICE, sdkp, sd_read_capacity() 2261 sdkp->capacity = 1 + (sector_t) 0xffffffff; sd_read_capacity() 2279 (sdp->guess_capacity && (sdkp->capacity & 0x01))) { sd_read_capacity() 2280 sd_printk(KERN_INFO, sdkp, "Adjusting the sector count " sd_read_capacity() 2282 (unsigned long long) sdkp->capacity); sd_read_capacity() 2283 --sdkp->capacity; sd_read_capacity() 2289 sd_printk(KERN_NOTICE, sdkp, "Sector size 0 reported, " sd_read_capacity() 2297 sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n", sd_read_capacity() 2305 sdkp->capacity = 0; sd_read_capacity() 2319 string_get_size(sdkp->capacity, sector_size, sd_read_capacity() 2321 string_get_size(sdkp->capacity, sector_size, sd_read_capacity() 2325 if (sdkp->first_scan || old_capacity != sdkp->capacity) { sd_read_capacity() 2326 sd_printk(KERN_NOTICE, sdkp, sd_read_capacity() 2328 (unsigned long long)sdkp->capacity, sd_read_capacity() 2331 if (sdkp->physical_block_size != sector_size) sd_read_capacity() 2332 sd_printk(KERN_NOTICE, sdkp, sd_read_capacity() 2334 sdkp->physical_block_size); sd_read_capacity() 2338 if (sdkp->capacity > 0xffffffff) sd_read_capacity() 2342 sdkp->physical_block_size); sd_read_capacity() 2343 sdkp->device->sector_size = sector_size; sd_read_capacity() 2362 sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer) sd_read_write_protect_flag() argument 2365 struct scsi_device *sdp = sdkp->device; sd_read_write_protect_flag() 2367 int old_wp = sdkp->write_prot; sd_read_write_protect_flag() 2369 set_disk_ro(sdkp->disk, 0); sd_read_write_protect_flag() 2371 sd_first_printk(KERN_NOTICE, sdkp, "Assuming Write Enabled\n"); sd_read_write_protect_flag() 2403 sd_first_printk(KERN_WARNING, sdkp, sd_read_write_protect_flag() 2406 sdkp->write_prot = ((data.device_specific & 0x80) != 0); sd_read_write_protect_flag() 2407 set_disk_ro(sdkp->disk, sdkp->write_prot); sd_read_write_protect_flag() 2408 if (sdkp->first_scan || old_wp != sdkp->write_prot) { sd_read_write_protect_flag() 2409 sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n", sd_read_write_protect_flag() 2410 sdkp->write_prot ? "on" : "off"); sd_read_write_protect_flag() 2411 sd_printk(KERN_DEBUG, sdkp, sd_read_write_protect_flag() 2423 sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) sd_read_cache_type() argument 2426 struct scsi_device *sdp = sdkp->device; sd_read_cache_type() 2433 int old_wce = sdkp->WCE; sd_read_cache_type() 2434 int old_rcd = sdkp->RCD; sd_read_cache_type() 2435 int old_dpofua = sdkp->DPOFUA; sd_read_cache_type() 2438 if (sdkp->cache_override) sd_read_cache_type() 2471 sd_first_printk(KERN_ERR, sdkp, sd_read_cache_type() 2485 sd_first_printk(KERN_NOTICE, sdkp, "Truncating mode parameter " sd_read_cache_type() 2508 sd_first_printk(KERN_ERR, sdkp, sd_read_cache_type() 2524 sd_first_printk(KERN_ERR, sdkp, sd_read_cache_type() 2532 sd_first_printk(KERN_ERR, sdkp, "No Caching mode page found\n"); sd_read_cache_type() 2537 sdkp->WCE = ((buffer[offset + 2] & 0x04) != 0); sd_read_cache_type() 2538 sdkp->RCD = ((buffer[offset + 2] & 0x01) != 0); sd_read_cache_type() 2540 sdkp->WCE = ((buffer[offset + 2] & 0x01) == 0); sd_read_cache_type() 2541 sdkp->RCD = 0; sd_read_cache_type() 2544 sdkp->DPOFUA = (data.device_specific & 0x10) != 0; sd_read_cache_type() 2546 sd_first_printk(KERN_NOTICE, sdkp, "Disabling FUA\n"); sd_read_cache_type() 2547 sdkp->DPOFUA = 0; sd_read_cache_type() 2548 } else if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) { sd_read_cache_type() 2549 sd_first_printk(KERN_NOTICE, sdkp, sd_read_cache_type() 2551 sdkp->DPOFUA = 0; sd_read_cache_type() 2555 if (sdkp->WCE && sdkp->write_prot) sd_read_cache_type() 2556 sdkp->WCE = 0; sd_read_cache_type() 2558 if (sdkp->first_scan || old_wce != sdkp->WCE || sd_read_cache_type() 2559 old_rcd != sdkp->RCD || old_dpofua != sdkp->DPOFUA) sd_read_cache_type() 2560 sd_printk(KERN_NOTICE, sdkp, sd_read_cache_type() 2562 sdkp->WCE ? "enabled" : "disabled", sd_read_cache_type() 2563 sdkp->RCD ? "disabled" : "enabled", sd_read_cache_type() 2564 sdkp->DPOFUA ? "supports DPO and FUA" sd_read_cache_type() 2575 sd_first_printk(KERN_NOTICE, sdkp, "Cache data unavailable\n"); sd_read_cache_type() 2577 sd_first_printk(KERN_ERR, sdkp, sd_read_cache_type() 2582 sd_first_printk(KERN_NOTICE, sdkp, sd_read_cache_type() 2584 sdkp->WCE = 1; sd_read_cache_type() 2586 sd_first_printk(KERN_ERR, sdkp, sd_read_cache_type() 2588 sdkp->WCE = 0; sd_read_cache_type() 2590 sdkp->RCD = 0; sd_read_cache_type() 2591 sdkp->DPOFUA = 0; sd_read_cache_type() 2598 static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer) sd_read_app_tag_own() argument 2601 struct scsi_device *sdp = sdkp->device; sd_read_app_tag_own() 2608 if (sdkp->protection_type == 0) sd_read_app_tag_own() 2616 sd_first_printk(KERN_WARNING, sdkp, sd_read_app_tag_own() 2620 sd_print_sense_hdr(sdkp, &sshdr); sd_read_app_tag_own() 2628 sd_first_printk(KERN_ERR, sdkp, "ATO Got wrong page\n"); sd_read_app_tag_own() 2635 sdkp->ATO = 1; sd_read_app_tag_own() 2644 static void sd_read_block_limits(struct scsi_disk *sdkp) sd_read_block_limits() argument 2646 unsigned int sector_sz = sdkp->device->sector_size; sd_read_block_limits() 2652 scsi_get_vpd_page(sdkp->device, 0xb0, buffer, vpd_len)) sd_read_block_limits() 2655 blk_queue_io_min(sdkp->disk->queue, sd_read_block_limits() 2658 sdkp->max_xfer_blocks = get_unaligned_be32(&buffer[8]); sd_read_block_limits() 2659 sdkp->opt_xfer_blocks = get_unaligned_be32(&buffer[12]); sd_read_block_limits() 2664 sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]); sd_read_block_limits() 2666 if (!sdkp->lbpme) sd_read_block_limits() 2673 sdkp->max_unmap_blocks = lba_count; sd_read_block_limits() 2675 sdkp->unmap_granularity = get_unaligned_be32(&buffer[28]); sd_read_block_limits() 2678 sdkp->unmap_alignment = sd_read_block_limits() 2681 if (!sdkp->lbpvpd) { /* LBP VPD page not provided */ sd_read_block_limits() 2683 if (sdkp->max_unmap_blocks) sd_read_block_limits() 2684 sd_config_discard(sdkp, SD_LBP_UNMAP); sd_read_block_limits() 2686 sd_config_discard(sdkp, SD_LBP_WS16); sd_read_block_limits() 2689 if (sdkp->lbpu && sdkp->max_unmap_blocks && !sdkp->lbprz) sd_read_block_limits() 2690 sd_config_discard(sdkp, SD_LBP_UNMAP); sd_read_block_limits() 2691 else if (sdkp->lbpws) sd_read_block_limits() 2692 sd_config_discard(sdkp, SD_LBP_WS16); sd_read_block_limits() 2693 else if (sdkp->lbpws10) sd_read_block_limits() 2694 sd_config_discard(sdkp, SD_LBP_WS10); sd_read_block_limits() 2695 else if (sdkp->lbpu && sdkp->max_unmap_blocks) sd_read_block_limits() 2696 sd_config_discard(sdkp, SD_LBP_UNMAP); sd_read_block_limits() 2698 sd_config_discard(sdkp, SD_LBP_DISABLE); sd_read_block_limits() 2710 static void sd_read_block_characteristics(struct scsi_disk *sdkp) sd_read_block_characteristics() argument 2720 scsi_get_vpd_page(sdkp->device, 0xb1, buffer, vpd_len)) sd_read_block_characteristics() 2726 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, sdkp->disk->queue); sd_read_block_characteristics() 2727 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, sdkp->disk->queue); sd_read_block_characteristics() 2738 static void sd_read_block_provisioning(struct scsi_disk *sdkp) sd_read_block_provisioning() argument 2743 if (sdkp->lbpme == 0) sd_read_block_provisioning() 2748 if (!buffer || scsi_get_vpd_page(sdkp->device, 0xb2, buffer, vpd_len)) sd_read_block_provisioning() 2751 sdkp->lbpvpd = 1; sd_read_block_provisioning() 2752 sdkp->lbpu = (buffer[5] >> 7) & 1; /* UNMAP */ sd_read_block_provisioning() 2753 sdkp->lbpws = (buffer[5] >> 6) & 1; /* WRITE SAME(16) with UNMAP */ sd_read_block_provisioning() 2754 sdkp->lbpws10 = (buffer[5] >> 5) & 1; /* WRITE SAME(10) with UNMAP */ sd_read_block_provisioning() 2760 static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer) sd_read_write_same() argument 2762 struct scsi_device *sdev = sdkp->device; sd_read_write_same() 2785 sdkp->ws16 = 1; sd_read_write_same() 2788 sdkp->ws10 = 1; sd_read_write_same() 2815 struct scsi_disk *sdkp = scsi_disk(disk); sd_revalidate_disk() local 2816 struct scsi_device *sdp = sdkp->device; sd_revalidate_disk() 2817 struct request_queue *q = sdkp->disk->queue; sd_revalidate_disk() 2821 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, sd_revalidate_disk() 2833 sd_printk(KERN_WARNING, sdkp, "sd_revalidate_disk: Memory " sd_revalidate_disk() 2838 sd_spinup_disk(sdkp); sd_revalidate_disk() 2844 if (sdkp->media_present) { sd_revalidate_disk() 2845 sd_read_capacity(sdkp, buffer); sd_revalidate_disk() 2848 sd_read_block_provisioning(sdkp); sd_revalidate_disk() 2849 sd_read_block_limits(sdkp); sd_revalidate_disk() 2850 sd_read_block_characteristics(sdkp); sd_revalidate_disk() 2853 sd_read_write_protect_flag(sdkp, buffer); sd_revalidate_disk() 2854 sd_read_cache_type(sdkp, buffer); sd_revalidate_disk() 2855 sd_read_app_tag_own(sdkp, buffer); sd_revalidate_disk() 2856 sd_read_write_same(sdkp, buffer); sd_revalidate_disk() 2859 sdkp->first_scan = 0; sd_revalidate_disk() 2865 sd_set_flush_flag(sdkp); sd_revalidate_disk() 2871 dev_max = min_not_zero(dev_max, sdkp->max_xfer_blocks); sd_revalidate_disk() 2879 if (sdkp->opt_xfer_blocks && sd_revalidate_disk() 2880 sdkp->opt_xfer_blocks <= dev_max && sd_revalidate_disk() 2881 sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS && sd_revalidate_disk() 2882 sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_CACHE_SIZE) sd_revalidate_disk() 2884 sdkp->opt_xfer_blocks * sdp->sector_size; sd_revalidate_disk() 2891 set_capacity(disk, logical_to_sectors(sdp, sdkp->capacity)); sd_revalidate_disk() 2892 sd_config_write_same(sdkp); sd_revalidate_disk() 2970 struct scsi_disk *sdkp = data; sd_probe_async() local 2976 sdp = sdkp->device; sd_probe_async() 2977 gd = sdkp->disk; sd_probe_async() 2978 index = sdkp->index; sd_probe_async() 2986 gd->private_data = &sdkp->driver; sd_probe_async() 2987 gd->queue = sdkp->device->request_queue; sd_probe_async() 2991 sdkp->capacity = 0; sd_probe_async() 2992 sdkp->media_present = 1; sd_probe_async() 2993 sdkp->write_prot = 0; sd_probe_async() 2994 sdkp->cache_override = 0; sd_probe_async() 2995 sdkp->WCE = 0; sd_probe_async() 2996 sdkp->RCD = 0; sd_probe_async() 2997 sdkp->ATO = 0; sd_probe_async() 2998 sdkp->first_scan = 1; sd_probe_async() 2999 sdkp->max_medium_access_timeouts = SD_MAX_MEDIUM_TIMEOUTS; sd_probe_async() 3012 if (sdkp->capacity) sd_probe_async() 3013 sd_dif_config_host(sdkp); sd_probe_async() 3017 sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n", sd_probe_async() 3020 put_device(&sdkp->dev); sd_probe_async() 3044 struct scsi_disk *sdkp; sd_probe() local 3058 sdkp = kzalloc(sizeof(*sdkp), GFP_KERNEL); sd_probe() 3059 if (!sdkp) sd_probe() 3086 sdkp->device = sdp; sd_probe() 3087 sdkp->driver = &sd_template; sd_probe() 3088 sdkp->disk = gd; sd_probe() 3089 sdkp->index = index; sd_probe() 3090 atomic_set(&sdkp->openers, 0); sd_probe() 3091 atomic_set(&sdkp->device->ioerr_cnt, 0); sd_probe() 3101 device_initialize(&sdkp->dev); sd_probe() 3102 sdkp->dev.parent = dev; sd_probe() 3103 sdkp->dev.class = &sd_disk_class; sd_probe() 3104 dev_set_name(&sdkp->dev, "%s", dev_name(dev)); sd_probe() 3106 error = device_add(&sdkp->dev); sd_probe() 3111 dev_set_drvdata(dev, sdkp); sd_probe() 3113 get_device(&sdkp->dev); /* prevent release before async_schedule */ sd_probe() 3114 async_schedule_domain(sd_probe_async, sdkp, &scsi_sd_probe_domain); sd_probe() 3125 kfree(sdkp); sd_probe() 3144 struct scsi_disk *sdkp; sd_remove() local 3147 sdkp = dev_get_drvdata(dev); sd_remove() 3148 devt = disk_devt(sdkp->disk); sd_remove() 3149 scsi_autopm_get_device(sdkp->device); sd_remove() 3153 device_del(&sdkp->dev); sd_remove() 3154 del_gendisk(sdkp->disk); sd_remove() 3162 put_device(&sdkp->dev); sd_remove() 3179 struct scsi_disk *sdkp = to_scsi_disk(dev); scsi_disk_release() local 3180 struct gendisk *disk = sdkp->disk; scsi_disk_release() 3183 ida_remove(&sd_index_ida, sdkp->index); scsi_disk_release() 3188 put_device(&sdkp->device->sdev_gendev); scsi_disk_release() 3190 kfree(sdkp); scsi_disk_release() 3193 static int sd_start_stop_device(struct scsi_disk *sdkp, int start) sd_start_stop_device() argument 3197 struct scsi_device *sdp = sdkp->device; sd_start_stop_device() 3212 sd_print_result(sdkp, "Start/Stop Unit failed", res); sd_start_stop_device() 3214 sd_print_sense_hdr(sdkp, &sshdr); sd_start_stop_device() 3235 struct scsi_disk *sdkp = dev_get_drvdata(dev); sd_shutdown() local 3237 if (!sdkp) sd_shutdown() 3243 if (sdkp->WCE && sdkp->media_present) { sd_shutdown() 3244 sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); sd_shutdown() 3245 sd_sync_cache(sdkp); sd_shutdown() 3248 if (system_state != SYSTEM_RESTART && sdkp->device->manage_start_stop) { sd_shutdown() 3249 sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); sd_shutdown() 3250 sd_start_stop_device(sdkp, 0); sd_shutdown() 3256 struct scsi_disk *sdkp = dev_get_drvdata(dev); sd_suspend_common() local 3259 if (!sdkp) /* E.g.: runtime suspend following sd_remove() */ sd_suspend_common() 3262 if (sdkp->WCE && sdkp->media_present) { sd_suspend_common() 3263 sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); sd_suspend_common() 3264 ret = sd_sync_cache(sdkp); sd_suspend_common() 3273 if (sdkp->device->manage_start_stop) { sd_suspend_common() 3274 sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); sd_suspend_common() 3276 ret = sd_start_stop_device(sdkp, 0); sd_suspend_common() 3297 struct scsi_disk *sdkp = dev_get_drvdata(dev); sd_resume() local 3299 if (!sdkp) /* E.g.: runtime resume at the start of sd_probe() */ sd_resume() 3302 if (!sdkp->device->manage_start_stop) sd_resume() 3305 sd_printk(KERN_NOTICE, sdkp, "Starting disk\n"); sd_resume() 3306 return sd_start_stop_device(sdkp, 1); sd_resume() 3397 static void sd_print_sense_hdr(struct scsi_disk *sdkp, sd_print_sense_hdr() argument 3400 scsi_print_sense_hdr(sdkp->device, sd_print_sense_hdr() 3401 sdkp->disk ? sdkp->disk->disk_name : NULL, sshdr); sd_print_sense_hdr() 3404 static void sd_print_result(const struct scsi_disk *sdkp, const char *msg, sd_print_result() argument 3411 sd_printk(KERN_INFO, sdkp, sd_print_result() 3416 sd_printk(KERN_INFO, sdkp, sd_print_result()
|