Lines Matching +full:sync +full:- +full:on +full:- +full:green
1 /*-
4 * SPDX-License-Identifier: BSD-2-Clause
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
84 * ATA -> LOGDIR -> IDDIR -> SUP -> ATA_ZONE
398 softc->delete_available |= (1 << delete_method); \
400 softc->delete_available &= ~(1 << delete_method); \
493 * 6-byte CDB.
521 * The STEC SSDs sometimes hang on UNMAP.
530 * Also VMware returns odd errors on misaligned UNMAPs.
538 * EXATELECOM (Sigmatel) i-Bead 100/105 USB Flash MP3 Player
541 {T_DIRECT, SIP_MEDIA_REMOVABLE, "EXATEL", "i-BEAD10*", "*"},
594 * SEAGRAND NP-900 MP3 Player
597 {T_DIRECT, SIP_MEDIA_REMOVABLE, "SEAGRAND", "NP-900*", "*"},
628 {T_DIRECT, SIP_MEDIA_REMOVABLE, "TEAC" , "FD-05*", "*"},
633 * Kingston DataTraveler II+ USB Pen-Drive.
678 {T_DIRECT, SIP_MEDIA_REMOVABLE, "USB-DISK", "FreeDik-FlashUsb",
699 * United MP5512 Portable MP3 Player (2-in-1 USB DISK/MP3)
745 * Genesys 6-in-1 Card Reader
756 {T_DIRECT, SIP_MEDIA_REMOVABLE, "CAMERA*", "4MP-9J6*",
777 * X-Micro Flash Disk
780 {T_DIRECT, SIP_MEDIA_REMOVABLE, "X-Micro", "Flash Disk",
825 * I/O Magic USB flash - Giga Bank
828 {T_DIRECT, SIP_MEDIA_FIXED, "GS-Magic", "stor*", "*"},
849 * Storcase (Kingston) InfoStation IFS FC2/SATA-R 201A
852 {T_DIRECT, SIP_MEDIA_FIXED, "IFS", "FC2/SATA-R*",
857 * Samsung YP-U3 mp3-player
860 {T_DIRECT, SIP_MEDIA_REMOVABLE, "Samsung", "YP-U3",
869 * Sony Cyber-Shot DSC cameras
880 /* At least several Transcent USB sticks lie on RC16. */
885 /* ADATA USB sticks lie on RC16. */
891 * I-O Data USB Flash Disk
894 {T_DIRECT, SIP_MEDIA_REMOVABLE, "I-O DATA", "USB Flash Disk*",
943 /* Seagate Barracuda Green Advanced Format (4k) drives */
948 /* Seagate Barracuda Green Advanced Format (4k) drives */
953 /* Seagate Barracuda Green Advanced Format (4k) drives */
958 /* Seagate Barracuda Green Advanced Format (4k) drives */
963 /* Seagate Barracuda Green Advanced Format (4k) drives */
968 /* Seagate Barracuda Green Advanced Format (4k) drives */
1053 /* WDC Caviar Green Advanced Format (4k) drives */
1058 /* WDC Caviar Green Advanced Format (4k) drives */
1063 /* WDC Caviar Green Advanced Format (4k) drives */
1068 /* WDC Caviar Green Advanced Format (4k) drives */
1073 /* WDC Caviar Green Advanced Format (4k) drives */
1078 /* WDC Caviar Green Advanced Format (4k) drives */
1083 /* WDC Caviar Green Advanced Format (4k) drives */
1088 /* WDC Caviar Green Advanced Format (4k) drives */
1134 * Olympus digital cameras (C-3040ZOOM, C-2040ZOOM, C-1)
1142 * Olympus digital cameras (D-370)
1150 * Olympus digital cameras (E-100RS, E-10).
1158 * Olympus FE-210 camera
1180 * Laser MP3-2GA13 MP3 player
1200 { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "Corsair CSSD-F*", "*" },
1232 { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "M4-CT???M4SSD2*", "*" },
1240 { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "C300-CTFDDAC???MAG*",
1285 * Intel X25-M Series SSDs
1320 { T_DIRECT, SIP_MEDIA_FIXED, "*", "OCZ-AGILITY2*", "*" },
1328 { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "OCZ-AGILITY3*", "*" },
1352 { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "OCZ-VERTEX3*", "*" },
1360 { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "OCZ-VERTEX4*", "*" },
1441 * connected via SATA-to-SAS interposer and because of this
1465 * Hama Innostor USB-Stick
1481 * MX-ES USB Drive by Mach Xtreme
1594 "Disable detection of write-protected disks");
1655 "max -- also bogus"
1681 struct da_softc *softc = periph->softc; in da_periph_hold()
1683 cnt = atomic_fetchadd_int(&softc->ref_flags[token], 1); in da_periph_hold()
1685 panic("Re-holding for reason %d, cnt = %d", token, cnt); in da_periph_hold()
1694 struct da_softc *softc = periph->softc; in da_periph_unhold()
1699 cnt = atomic_fetchadd_int(&softc->ref_flags[token], -1); in da_periph_unhold()
1715 struct da_softc *softc = periph->softc; in da_periph_acquire()
1717 cnt = atomic_fetchadd_int(&softc->ref_flags[token], 1); in da_periph_acquire()
1719 panic("Re-refing for reason %d, cnt = %d", token, cnt); in da_periph_acquire()
1728 struct da_softc *softc = periph->softc; in da_periph_release()
1733 cnt = atomic_fetchadd_int(&softc->ref_flags[token], -1); in da_periph_release()
1743 struct da_softc *softc = periph->softc; in da_periph_release_locked()
1748 cnt = atomic_fetchadd_int(&softc->ref_flags[token], -1); in da_periph_release_locked()
1775 periph = (struct cam_periph *)dp->d_drv1; in daopen()
1787 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH, in daopen()
1790 softc = (struct da_softc *)periph->softc; in daopen()
1794 error = cam_periph_sleep(periph, &softc->disk->d_mediasize, PRIBIO, in daopen()
1797 xpt_print(periph->path, "unable to retrieve capacity data\n"); in daopen()
1799 if (periph->flags & CAM_PERIPH_INVALID) in daopen()
1802 if (error == 0 && (softc->flags & DA_FLAG_PACK_REMOVABLE) != 0 && in daopen()
1803 (softc->quirks & DA_Q_NO_PREVENT) == 0) in daopen()
1807 softc->flags &= ~DA_FLAG_PACK_INVALID; in daopen()
1808 softc->flags |= DA_FLAG_OPEN; in daopen()
1827 periph = (struct cam_periph *)dp->d_drv1; in daclose()
1828 softc = (struct da_softc *)periph->softc; in daclose()
1830 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH, in daclose()
1835 if ((softc->flags & DA_FLAG_DIRTY) != 0 && in daclose()
1836 (softc->quirks & DA_Q_NO_SYNC_CACHE) == 0 && in daclose()
1837 (softc->flags & DA_FLAG_PACK_INVALID) == 0) { in daclose()
1839 scsi_synchronize_cache(&ccb->csio, /*retries*/1, in daclose()
1845 softc->disk->d_devstat); in daclose()
1846 softc->flags &= ~DA_FLAG_DIRTY; in daclose()
1851 if ((softc->flags & DA_FLAG_PACK_REMOVABLE) != 0 && in daclose()
1852 (softc->quirks & DA_Q_NO_PREVENT) == 0) in daclose()
1863 if ((softc->flags & DA_FLAG_PACK_REMOVABLE) != 0) in daclose()
1864 softc->disk->d_devstat->flags |= DEVSTAT_BS_UNAVAILABLE; in daclose()
1866 softc->flags &= ~DA_FLAG_OPEN; in daclose()
1867 while (softc->refcount != 0) in daclose()
1868 cam_periph_sleep(periph, &softc->refcount, PRIBIO, "daclose", 1); in daclose()
1877 struct da_softc *softc = (struct da_softc *)periph->softc; in daschedule()
1879 if (softc->state != DA_STATE_NORMAL) in daschedule()
1882 cam_iosched_schedule(softc->cam_iosched, periph); in daschedule()
1896 periph = (struct cam_periph *)bp->bio_disk->d_drv1; in dastrategy()
1897 softc = (struct da_softc *)periph->softc; in dastrategy()
1904 if ((softc->flags & DA_FLAG_PACK_INVALID)) { in dastrategy()
1910 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dastrategy(%p)\n", bp)); in dastrategy()
1913 * Zone commands must be ordered, because they can depend on the in dastrategy()
1917 if (bp->bio_cmd == BIO_ZONE) in dastrategy()
1918 bp->bio_flags |= BIO_ORDERED; in dastrategy()
1923 cam_iosched_queue_work(softc->cam_iosched, bp); in dastrategy()
1945 periph = dp->d_drv1; in dadump()
1946 softc = (struct da_softc *)periph->softc; in dadump()
1947 secsize = softc->params.secsize; in dadump()
1949 if ((softc->flags & DA_FLAG_PACK_INVALID) != 0) in dadump()
1954 xpt_setup_ccb(&csio.ccb_h, periph->path, CAM_PRIORITY_NORMAL); in dadump()
1962 /*minimum_cmd_size*/ softc->minimum_cmd_size, in dadump()
1977 * Sync the disk cache contents to the physical media. in dadump()
1979 if ((softc->quirks & DA_Q_NO_SYNC_CACHE) == 0) { in dadump()
1980 xpt_setup_ccb(&csio.ccb_h, periph->path, CAM_PRIORITY_NORMAL); in dadump()
1993 xpt_print(periph->path, "Synchronize cache failed\n"); in dadump()
2007 periph = (struct cam_periph *)bp->bio_disk->d_drv1; in dagetattr()
2009 ret = xpt_getattr(bp->bio_data, bp->bio_length, bp->bio_attribute, in dagetattr()
2010 periph->path); in dagetattr()
2013 bp->bio_completed = bp->bio_length; in dagetattr()
2052 periph = (struct cam_periph *)dp->d_drv1; in dadiskgonecb()
2062 softc = (struct da_softc *)periph->softc; in daoninvalidate()
2065 * De-register any async callbacks. in daoninvalidate()
2067 xpt_register_async(0, daasync, periph, periph->path); in daoninvalidate()
2069 softc->flags |= DA_FLAG_PACK_INVALID; in daoninvalidate()
2071 softc->invalidations++; in daoninvalidate()
2080 cam_iosched_flush(softc->cam_iosched, NULL, ENXIO); in daoninvalidate()
2086 disk_gone(softc->disk); in daoninvalidate()
2094 softc = (struct da_softc *)periph->softc; in dacleanup()
2098 cam_iosched_fini(softc->cam_iosched); in dacleanup()
2103 if ((softc->flags & DA_FLAG_SCTX_INIT) != 0) { in dacleanup()
2105 if (sysctl_ctx_free(&softc->sysctl_stats_ctx) != 0) in dacleanup()
2106 xpt_print(periph->path, in dacleanup()
2109 if (sysctl_ctx_free(&softc->sysctl_ctx) != 0) in dacleanup()
2110 xpt_print(periph->path, in dacleanup()
2114 callout_drain(&softc->mediapoll_c); in dacleanup()
2115 disk_destroy(softc->disk); in dacleanup()
2116 callout_drain(&softc->sendordered_c); in dacleanup()
2139 if (cgd->protocol != PROTO_SCSI) in daasync()
2141 if (SID_QUAL(&cgd->inq_data) != SID_QUAL_LU_CONNECTED) in daasync()
2143 if (SID_TYPE(&cgd->inq_data) != T_DIRECT in daasync()
2144 && SID_TYPE(&cgd->inq_data) != T_RBC in daasync()
2145 && SID_TYPE(&cgd->inq_data) != T_OPTICAL in daasync()
2146 && SID_TYPE(&cgd->inq_data) != T_ZBC_HM) in daasync()
2174 softc = periph->softc; in daasync()
2175 disk_attr_changed(softc->disk, "GEOM::physpath", in daasync()
2185 softc = (struct da_softc *)periph->softc; in daasync()
2192 if (xpt_path_periph(ccb->ccb_h.path) != periph && in daasync()
2197 xpt_print(ccb->ccb_h.path, in daasync()
2200 softc->flags &= ~DA_FLAG_PROBED; in daasync()
2205 softc->flags &= ~DA_FLAG_PROBED; in daasync()
2206 disk_media_changed(softc->disk, M_NOWAIT); in daasync()
2209 xpt_print(ccb->ccb_h.path, in daasync()
2212 softc->flags &= ~DA_FLAG_PROBED; in daasync()
2224 softc = (struct da_softc *)periph->softc; in daasync()
2225 if (!cam_iosched_has_work_flags(softc->cam_iosched, DA_WORK_TUR) && in daasync()
2226 (softc->flags & DA_FLAG_TUR_PENDING) == 0) { in daasync()
2228 cam_iosched_set_work_flags(softc->cam_iosched, DA_WORK_TUR); in daasync()
2239 softc = (struct da_softc *)periph->softc; in daasync()
2241 * Don't fail on the expected unit attention in daasync()
2244 softc->flags |= DA_FLAG_RETRY_UA; in daasync()
2245 LIST_FOREACH(ccbh, &softc->pending_ccbs, periph_links.le) in daasync()
2246 ccbh->ccb_state |= DA_CCB_RETRY_UA; in daasync()
2251 softc = (struct da_softc *)periph->softc; in daasync()
2252 softc->flags &= ~DA_FLAG_PROBED; in daasync()
2273 if (periph->flags & CAM_PERIPH_INVALID) { in dasysctlinit()
2278 softc = (struct da_softc *)periph->softc; in dasysctlinit()
2279 snprintf(tmpstr, sizeof(tmpstr), "CAM DA unit %d", periph->unit_number); in dasysctlinit()
2280 snprintf(tmpstr2, sizeof(tmpstr2), "%d", periph->unit_number); in dasysctlinit()
2282 sysctl_ctx_init(&softc->sysctl_ctx); in dasysctlinit()
2284 softc->flags |= DA_FLAG_SCTX_INIT; in dasysctlinit()
2286 softc->sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&softc->sysctl_ctx, in dasysctlinit()
2289 if (softc->sysctl_tree == NULL) { in dasysctlinit()
2296 * Now register the sysctl handler, so the user can change the value on in dasysctlinit()
2299 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in dasysctlinit()
2304 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in dasysctlinit()
2309 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in dasysctlinit()
2312 &softc->minimum_cmd_size, 0, dacmdsizesysctl, "I", in dasysctlinit()
2314 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in dasysctlinit()
2315 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in dasysctlinit()
2316 "trim_count", CTLFLAG_RD, &softc->trim_count, in dasysctlinit()
2318 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in dasysctlinit()
2319 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in dasysctlinit()
2320 "trim_ranges", CTLFLAG_RD, &softc->trim_ranges, in dasysctlinit()
2322 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in dasysctlinit()
2323 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in dasysctlinit()
2324 "trim_lbas", CTLFLAG_RD, &softc->trim_lbas, in dasysctlinit()
2327 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in dasysctlinit()
2332 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in dasysctlinit()
2337 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in dasysctlinit()
2338 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in dasysctlinit()
2339 "optimal_seq_zones", CTLFLAG_RD, &softc->optimal_seq_zones, in dasysctlinit()
2341 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in dasysctlinit()
2342 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in dasysctlinit()
2344 &softc->optimal_nonseq_zones, in dasysctlinit()
2345 "Optimal Number of Non-Sequentially Written Sequential Write " in dasysctlinit()
2347 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in dasysctlinit()
2348 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in dasysctlinit()
2349 "max_seq_zones", CTLFLAG_RD, &softc->max_seq_zones, in dasysctlinit()
2352 SYSCTL_ADD_INT(&softc->sysctl_ctx, in dasysctlinit()
2353 SYSCTL_CHILDREN(softc->sysctl_tree), in dasysctlinit()
2357 &softc->error_inject, in dasysctlinit()
2361 SYSCTL_ADD_INT(&softc->sysctl_ctx, in dasysctlinit()
2362 SYSCTL_CHILDREN(softc->sysctl_tree), in dasysctlinit()
2366 &softc->p_type, in dasysctlinit()
2370 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in dasysctlinit()
2374 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in dasysctlinit()
2376 &softc->flags, (u_int)DA_FLAG_ROTATING, dabitsysctl, "I", in dasysctlinit()
2378 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in dasysctlinit()
2380 &softc->flags, (u_int)DA_FLAG_UNMAPPEDIO, dabitsysctl, "I", in dasysctlinit()
2384 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in dasysctlinit()
2394 xpt_setup_ccb(&cts.ccb_h, periph->path, CAM_PRIORITY_NONE); in dasysctlinit()
2406 if (fc->valid & CTS_FC_VALID_WWPN) { in dasysctlinit()
2407 softc->wwpn = fc->wwpn; in dasysctlinit()
2408 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in dasysctlinit()
2409 SYSCTL_CHILDREN(softc->sysctl_tree), in dasysctlinit()
2411 &softc->wwpn, "World Wide Port Name"); in dasysctlinit()
2420 softc->sysctl_stats_tree = SYSCTL_ADD_NODE(&softc->sysctl_stats_ctx, in dasysctlinit()
2421 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "stats", in dasysctlinit()
2423 SYSCTL_ADD_INT(&softc->sysctl_stats_ctx, in dasysctlinit()
2424 SYSCTL_CHILDREN(softc->sysctl_stats_tree), in dasysctlinit()
2428 &softc->errors, in dasysctlinit()
2431 SYSCTL_ADD_INT(&softc->sysctl_stats_ctx, in dasysctlinit()
2432 SYSCTL_CHILDREN(softc->sysctl_stats_tree), in dasysctlinit()
2436 &softc->timeouts, in dasysctlinit()
2439 SYSCTL_ADD_INT(&softc->sysctl_stats_ctx, in dasysctlinit()
2440 SYSCTL_CHILDREN(softc->sysctl_stats_tree), in dasysctlinit()
2444 &softc->invalidations, in dasysctlinit()
2449 cam_iosched_sysctl_init(softc->cam_iosched, &softc->sysctl_ctx, in dasysctlinit()
2450 softc->sysctl_tree); in dasysctlinit()
2464 value = softc->disk->d_delmaxsize; in dadeletemaxsysctl()
2466 if ((error != 0) || (req->newptr == NULL)) in dadeletemaxsysctl()
2470 if (value > dadeletemaxsize(softc, softc->delete_method)) { in dadeletemaxsysctl()
2473 softc->disk->d_delmaxsize = value; in dadeletemaxsysctl()
2488 || (req->newptr == NULL)) in dacmdsizesysctl()
2519 if ((error != 0) || (req->newptr == NULL)) in dasysctlsofttimeout()
2534 softc->delete_method = delete_method; in dadeletemethodset()
2535 softc->disk->d_delmaxsize = dadeletemaxsize(softc, delete_method); in dadeletemethodset()
2536 softc->delete_func = da_delete_functions[delete_method]; in dadeletemethodset()
2538 if (softc->delete_method > DA_DELETE_DISABLE) in dadeletemethodset()
2539 softc->disk->d_flags |= DISKFLAG_CANDELETE; in dadeletemethodset()
2541 softc->disk->d_flags &= ~DISKFLAG_CANDELETE; in dadeletemethodset()
2551 sectors = (off_t)softc->unmap_max_lba; in dadeletemaxsize()
2554 sectors = (off_t)ATA_DSM_RANGE_MAX * softc->trim_max_ranges; in dadeletemaxsize()
2557 sectors = omin(softc->ws_max_blks, WS16_MAX_BLKS); in dadeletemaxsize()
2561 sectors = omin(softc->ws_max_blks, WS10_MAX_BLKS); in dadeletemaxsize()
2567 return (off_t)softc->params.secsize * in dadeletemaxsize()
2568 omin(sectors, softc->params.sectors); in dadeletemaxsize()
2576 softc = (struct da_softc *)periph->softc; in daprobedone()
2582 if (bootverbose && (softc->flags & DA_FLAG_ANNOUNCED) == 0) { in daprobedone()
2589 if ((softc->delete_available & (1 << i)) == 0 && in daprobedone()
2590 i != softc->delete_method) in daprobedone()
2596 if (i == softc->delete_method) in daprobedone()
2601 printf("%s%d: %s\n", periph->periph_name, in daprobedone()
2602 periph->unit_number, buf); in daprobedone()
2604 if ((softc->disk->d_flags & DISKFLAG_WRITE_PROTECT) != 0 && in daprobedone()
2605 (softc->flags & DA_FLAG_ANNOUNCED) == 0) { in daprobedone()
2606 printf("%s%d: Write Protected\n", periph->periph_name, in daprobedone()
2607 periph->unit_number); in daprobedone()
2613 * before releasing the probe lock on the peripheral. in daprobedone()
2619 softc->state = DA_STATE_NORMAL; in daprobedone()
2620 softc->flags |= DA_FLAG_PROBED; in daprobedone()
2622 wakeup(&softc->disk->d_mediasize); in daprobedone()
2623 if ((softc->flags & DA_FLAG_ANNOUNCED) == 0) { in daprobedone()
2624 softc->flags |= DA_FLAG_ANNOUNCED; in daprobedone()
2631 disk_create(softc->disk, DISK_VERSION); in daprobedone()
2644 i = softc->delete_method_pref; in dadeletemethodchoose()
2645 methods = softc->delete_available | (1 << DA_DELETE_DISABLE); in dadeletemethodchoose()
2651 /* Use the pre-defined order to choose the best performing delete. */ in dadeletemethodchoose()
2655 if (softc->delete_available & (1 << i)) { in dadeletemethodchoose()
2674 if (error || !req->newptr) in dabitsysctl()
2688 if (softc->flags != 0) in daflagssysctl()
2689 sbuf_printf(&sbuf, "0x%b", (unsigned)softc->flags, DA_FLAG_STRING); in daflagssysctl()
2708 value = softc->delete_method; in dadeletemethodsysctl()
2715 if (error != 0 || req->newptr == NULL) in dadeletemethodsysctl()
2723 softc->delete_method_pref = i; in dadeletemethodsysctl()
2737 switch (softc->zone_mode) { in dazonemodesysctl()
2773 if (softc->zone_flags & da_zone_desc_table[i].value) { in dazonesupsysctl()
2815 LIST_INIT(&softc->pending_ccbs); in daregister()
2816 softc->state = DA_STATE_PROBE_WP; in daregister()
2817 bioq_init(&softc->delete_run_queue); in daregister()
2818 if (SID_IS_REMOVABLE(&cgd->inq_data)) in daregister()
2819 softc->flags |= DA_FLAG_PACK_REMOVABLE; in daregister()
2820 softc->unmap_max_ranges = UNMAP_MAX_RANGES; in daregister()
2821 softc->unmap_max_lba = UNMAP_RANGE_MAX; in daregister()
2822 softc->unmap_gran = 0; in daregister()
2823 softc->unmap_gran_align = 0; in daregister()
2824 softc->ws_max_blks = WS16_MAX_BLKS; in daregister()
2825 softc->trim_max_ranges = ATA_TRIM_MAX_RANGES; in daregister()
2826 softc->flags |= DA_FLAG_ROTATING; in daregister()
2828 periph->softc = softc; in daregister()
2833 match = cam_quirkmatch((caddr_t)&cgd->inq_data, in daregister()
2839 softc->quirks = ((struct da_quirk_entry *)match)->quirks; in daregister()
2841 softc->quirks = DA_Q_NONE; in daregister()
2844 xpt_path_inq(&cpi, periph->path); in daregister()
2846 softc->quirks |= DA_Q_NO_6_BYTE; in daregister()
2850 periph->unit_number); in daregister()
2851 quirks = softc->quirks; in daregister()
2853 softc->quirks = quirks; in daregister()
2855 if (SID_TYPE(&cgd->inq_data) == T_ZBC_HM) in daregister()
2856 softc->zone_mode = DA_ZONE_HOST_MANAGED; in daregister()
2857 else if (softc->quirks & DA_Q_SMR_DM) in daregister()
2858 softc->zone_mode = DA_ZONE_DRIVE_MANAGED; in daregister()
2860 softc->zone_mode = DA_ZONE_NONE; in daregister()
2862 if (softc->zone_mode != DA_ZONE_NONE) { in daregister()
2865 softc->zone_interface = DA_ZONE_IF_ATA_SAT; in daregister()
2867 softc->zone_interface = DA_ZONE_IF_ATA_PASS; in daregister()
2869 softc->zone_interface = DA_ZONE_IF_SCSI; in daregister()
2872 TASK_INIT(&softc->sysctl_task, 0, dasysctlinit, periph); in daregister()
2875 * Let XPT know we can use UMA-allocated CCBs. in daregister()
2880 periph->ccb_zone = da_ccb_zone; in daregister()
2884 * Take a reference on the periph while dastart is called to finish the in daregister()
2893 callout_init_mtx(&softc->sendordered_c, cam_periph_mtx(periph), 0); in daregister()
2894 callout_reset_sbt(&softc->sendordered_c, in daregister()
2902 if (softc->quirks & DA_Q_NO_6_BYTE || SID_TYPE(&cgd->inq_data) == T_RBC) in daregister()
2903 softc->minimum_cmd_size = 10; in daregister()
2905 softc->minimum_cmd_size = 6; in daregister()
2911 periph->unit_number); in daregister()
2912 TUNABLE_INT_FETCH(tmpstr, &softc->minimum_cmd_size); in daregister()
2917 if (softc->minimum_cmd_size > 12) in daregister()
2918 softc->minimum_cmd_size = 16; in daregister()
2919 else if (softc->minimum_cmd_size > 10) in daregister()
2920 softc->minimum_cmd_size = 12; in daregister()
2921 else if (softc->minimum_cmd_size > 6) in daregister()
2922 softc->minimum_cmd_size = 10; in daregister()
2924 softc->minimum_cmd_size = 6; in daregister()
2926 /* On first PROBE_WP request all more pages, then adjust. */ in daregister()
2927 softc->mode_page = SMS_ALL_PAGES_PAGE; in daregister()
2930 if (SID_ANSI_REV(&cgd->inq_data) >= SCSI_REV_SPC3 && in daregister()
2931 (softc->quirks & DA_Q_NO_RC16) == 0) { in daregister()
2932 softc->flags |= DA_FLAG_CAN_RC16; in daregister()
2938 softc->disk = disk_alloc(); in daregister()
2939 softc->disk->d_devstat = devstat_new_entry(periph->periph_name, in daregister()
2940 periph->unit_number, 0, in daregister()
2942 SID_TYPE(&cgd->inq_data) | in daregister()
2945 softc->disk->d_open = daopen; in daregister()
2946 softc->disk->d_close = daclose; in daregister()
2947 softc->disk->d_strategy = dastrategy; in daregister()
2948 if (cam_sim_pollable(periph->sim)) in daregister()
2949 softc->disk->d_dump = dadump; in daregister()
2950 softc->disk->d_getattr = dagetattr; in daregister()
2951 softc->disk->d_gone = dadiskgonecb; in daregister()
2952 softc->disk->d_name = "da"; in daregister()
2953 softc->disk->d_drv1 = periph; in daregister()
2955 softc->maxio = DFLTPHYS; /* traditional default */ in daregister()
2957 softc->maxio = maxphys; /* for safety */ in daregister()
2959 softc->maxio = cpi.maxio; in daregister()
2960 if (softc->quirks & DA_Q_128KB) in daregister()
2961 softc->maxio = min(softc->maxio, 128 * 1024); in daregister()
2962 softc->disk->d_maxsize = softc->maxio; in daregister()
2963 softc->disk->d_unit = periph->unit_number; in daregister()
2964 softc->disk->d_flags = DISKFLAG_DIRECT_COMPLETION | DISKFLAG_CANZONE; in daregister()
2965 if ((softc->quirks & DA_Q_NO_SYNC_CACHE) == 0) in daregister()
2966 softc->disk->d_flags |= DISKFLAG_CANFLUSHCACHE; in daregister()
2968 softc->flags |= DA_FLAG_UNMAPPEDIO; in daregister()
2969 softc->disk->d_flags |= DISKFLAG_UNMAPPED_BIO; in daregister()
2971 cam_strvis(softc->disk->d_descr, cgd->inq_data.vendor, in daregister()
2972 sizeof(cgd->inq_data.vendor), sizeof(softc->disk->d_descr)); in daregister()
2973 strlcat(softc->disk->d_descr, " ", sizeof(softc->disk->d_descr)); in daregister()
2974 cam_strvis(&softc->disk->d_descr[strlen(softc->disk->d_descr)], in daregister()
2975 cgd->inq_data.product, sizeof(cgd->inq_data.product), in daregister()
2976 sizeof(softc->disk->d_descr) - strlen(softc->disk->d_descr)); in daregister()
2977 softc->disk->d_hba_vendor = cpi.hba_vendor; in daregister()
2978 softc->disk->d_hba_device = cpi.hba_device; in daregister()
2979 softc->disk->d_hba_subvendor = cpi.hba_subvendor; in daregister()
2980 softc->disk->d_hba_subdevice = cpi.hba_subdevice; in daregister()
2981 snprintf(softc->disk->d_attachment, sizeof(softc->disk->d_attachment), in daregister()
2984 if (cam_iosched_init(&softc->cam_iosched, periph, softc->disk, in daregister()
2997 * would be to not attach the device on failure. in daregister()
3002 AC_INQ_CHANGED, daasync, periph, periph->path); in daregister()
3007 callout_init_mtx(&softc->mediapoll_c, cam_periph_mtx(periph), 0); in daregister()
3008 if ((softc->flags & DA_FLAG_PACK_REMOVABLE) && in daregister()
3009 (cgd->inq_flags & SID_AEN) == 0 && in daregister()
3011 callout_reset_sbt(&softc->mediapoll_c, da_poll_period * SBT_1S, in daregister()
3036 return -1; in da_zone_bio_to_scsi()
3048 if (bp->bio_cmd != BIO_ZONE) { in da_zone_cmd()
3053 softc = periph->softc; in da_zone_cmd()
3055 switch (bp->bio_zone.zone_cmd) { in da_zone_cmd()
3064 zone_sa = da_zone_bio_to_scsi(bp->bio_zone.zone_cmd); in da_zone_cmd()
3065 if (zone_sa == -1) { in da_zone_cmd()
3066 xpt_print(periph->path, "Cannot translate zone " in da_zone_cmd()
3067 "cmd %#x to SCSI\n", bp->bio_zone.zone_cmd); in da_zone_cmd()
3073 lba = bp->bio_zone.zone_params.rwp.id; in da_zone_cmd()
3075 if (bp->bio_zone.zone_params.rwp.flags & in da_zone_cmd()
3079 if (softc->zone_interface != DA_ZONE_IF_ATA_PASS) { in da_zone_cmd()
3080 scsi_zbc_out(&ccb->csio, in da_zone_cmd()
3096 * 1. It hasn't been tested on a SAT layer that in da_zone_cmd()
3097 * supports it. This is new as of SAT-4. in da_zone_cmd()
3100 * ZBC -> ZAC translation, since they are both in da_zone_cmd()
3101 * in the SAT-4 spec. in da_zone_cmd()
3109 * 4. It requires a 32-byte CDB, which at least at in da_zone_cmd()
3114 error = scsi_ata_zac_mgmt_out(&ccb->csio, in da_zone_cmd()
3130 xpt_print(periph->path, in da_zone_cmd()
3145 rep = &bp->bio_zone.zone_params.report; in da_zone_cmd()
3147 num_entries = rep->entries_allocated; in da_zone_cmd()
3149 xpt_print(periph->path, "No entries allocated for " in da_zone_cmd()
3156 alloc_size = min(alloc_size, softc->disk->d_maxsize); in da_zone_cmd()
3159 xpt_print(periph->path, "Unable to allocate memory " in da_zone_cmd()
3165 if (softc->zone_interface != DA_ZONE_IF_ATA_PASS) { in da_zone_cmd()
3166 scsi_zbc_in(&ccb->csio, in da_zone_cmd()
3171 /*zone_start_lba*/ rep->starting_id, in da_zone_cmd()
3172 /*zone_options*/ rep->rep_options, in da_zone_cmd()
3182 * 1. It hasn't been tested on a SAT layer that in da_zone_cmd()
3183 * supports it. This is new as of SAT-4. in da_zone_cmd()
3186 * ZBC -> ZAC translation, since they are both in da_zone_cmd()
3187 * in the SAT-4 spec. in da_zone_cmd()
3195 * 4. It requires a 32-byte CDB, which at least at in da_zone_cmd()
3200 error = scsi_ata_zac_mgmt_in(&ccb->csio, in da_zone_cmd()
3206 /*zone_id*/ rep->starting_id, in da_zone_cmd()
3207 /*zone_flags*/ rep->rep_options, in da_zone_cmd()
3216 xpt_print(periph->path, in da_zone_cmd()
3230 * it. devstat uses bio_bcount - bio_resid to calculate in da_zone_cmd()
3232 * uses bio_length - bio_resid to calculate the amount of in da_zone_cmd()
3247 bp->bio_bcount = bp->bio_length; in da_zone_cmd()
3256 params = &bp->bio_zone.zone_params.disk_params; in da_zone_cmd()
3259 switch (softc->zone_mode) { in da_zone_cmd()
3261 params->zone_mode = DISK_ZONE_MODE_DRIVE_MANAGED; in da_zone_cmd()
3264 params->zone_mode = DISK_ZONE_MODE_HOST_AWARE; in da_zone_cmd()
3267 params->zone_mode = DISK_ZONE_MODE_HOST_MANAGED; in da_zone_cmd()
3271 params->zone_mode = DISK_ZONE_MODE_NONE; in da_zone_cmd()
3275 if (softc->zone_flags & DA_ZONE_FLAG_URSWRZ) in da_zone_cmd()
3276 params->flags |= DISK_ZONE_DISK_URSWRZ; in da_zone_cmd()
3278 if (softc->zone_flags & DA_ZONE_FLAG_OPT_SEQ_SET) { in da_zone_cmd()
3279 params->optimal_seq_zones = softc->optimal_seq_zones; in da_zone_cmd()
3280 params->flags |= DISK_ZONE_OPT_SEQ_SET; in da_zone_cmd()
3283 if (softc->zone_flags & DA_ZONE_FLAG_OPT_NONSEQ_SET) { in da_zone_cmd()
3284 params->optimal_nonseq_zones = in da_zone_cmd()
3285 softc->optimal_nonseq_zones; in da_zone_cmd()
3286 params->flags |= DISK_ZONE_OPT_NONSEQ_SET; in da_zone_cmd()
3289 if (softc->zone_flags & DA_ZONE_FLAG_MAX_SEQ_SET) { in da_zone_cmd()
3290 params->max_seq_zones = softc->max_seq_zones; in da_zone_cmd()
3291 params->flags |= DISK_ZONE_MAX_SEQ_SET; in da_zone_cmd()
3293 if (softc->zone_flags & DA_ZONE_FLAG_RZ_SUP) in da_zone_cmd()
3294 params->flags |= DISK_ZONE_RZ_SUP; in da_zone_cmd()
3296 if (softc->zone_flags & DA_ZONE_FLAG_OPEN_SUP) in da_zone_cmd()
3297 params->flags |= DISK_ZONE_OPEN_SUP; in da_zone_cmd()
3299 if (softc->zone_flags & DA_ZONE_FLAG_CLOSE_SUP) in da_zone_cmd()
3300 params->flags |= DISK_ZONE_CLOSE_SUP; in da_zone_cmd()
3302 if (softc->zone_flags & DA_ZONE_FLAG_FINISH_SUP) in da_zone_cmd()
3303 params->flags |= DISK_ZONE_FINISH_SUP; in da_zone_cmd()
3305 if (softc->zone_flags & DA_ZONE_FLAG_RWP_SUP) in da_zone_cmd()
3306 params->flags |= DISK_ZONE_RWP_SUP; in da_zone_cmd()
3322 softc = (struct da_softc *)periph->softc; in dastart()
3324 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dastart\n")); in dastart()
3327 switch (softc->state) { in dastart()
3334 bp = cam_iosched_next_bio(softc->cam_iosched); in dastart()
3336 if (cam_iosched_has_work_flags(softc->cam_iosched, in dastart()
3338 softc->flags |= DA_FLAG_TUR_PENDING; in dastart()
3339 cam_iosched_clr_work_flags(softc->cam_iosched, in dastart()
3341 scsi_test_unit_ready(&start_ccb->csio, in dastart()
3347 start_ccb->ccb_h.ccb_bp = NULL; in dastart()
3348 start_ccb->ccb_h.ccb_state = DA_CCB_TUR; in dastart()
3355 if (bp->bio_cmd == BIO_DELETE) { in dastart()
3356 if (softc->delete_func != NULL) { in dastart()
3357 softc->delete_func(periph, start_ccb, bp); in dastart()
3369 if (cam_iosched_has_work_flags(softc->cam_iosched, in dastart()
3371 cam_iosched_clr_work_flags(softc->cam_iosched, in dastart()
3376 if ((bp->bio_flags & BIO_ORDERED) != 0 || in dastart()
3377 (softc->flags & DA_FLAG_NEED_OTAG) != 0) { in dastart()
3378 softc->flags &= ~DA_FLAG_NEED_OTAG; in dastart()
3379 softc->flags |= DA_FLAG_WAS_OTAG; in dastart()
3385 switch (bp->bio_cmd) { in dastart()
3394 if (bp->bio_cmd == BIO_WRITE) { in dastart()
3395 softc->flags |= DA_FLAG_DIRTY; in dastart()
3401 data_ptr = bp->bio_data; in dastart()
3402 if ((bp->bio_flags & (BIO_UNMAPPED|BIO_VLIST)) != 0) { in dastart()
3407 scsi_read_write(&start_ccb->csio, in dastart()
3413 softc->minimum_cmd_size, in dastart()
3414 /*lba*/bp->bio_pblkno, in dastart()
3415 /*block_count*/bp->bio_bcount / in dastart()
3416 softc->params.secsize, in dastart()
3418 /*dxfer_len*/ bp->bio_bcount, in dastart()
3422 start_ccb->csio.bio = bp; in dastart()
3428 * If we don't support sync cache, or the disk in dastart()
3429 * isn't dirty, FLUSH is a no-op. Use the in dastart()
3433 if ((softc->quirks & DA_Q_NO_SYNC_CACHE) != 0 || in dastart()
3434 (softc->flags & DA_FLAG_DIRTY) == 0) { in dastart()
3444 scsi_synchronize_cache(&start_ccb->csio, in dastart()
3454 * Either this sync cache will be successful, or it in dastart()
3460 softc->flags &= ~DA_FLAG_DIRTY; in dastart()
3490 start_ccb->ccb_h.ccb_state = DA_CCB_BUFFER_IO; in dastart()
3491 start_ccb->ccb_h.flags |= CAM_UNLOCKED; in dastart()
3492 start_ccb->ccb_h.softtimeout = sbttotv(da_default_softtimeout); in dastart()
3495 LIST_INSERT_HEAD(&softc->pending_ccbs, in dastart()
3496 &start_ccb->ccb_h, periph_links.le); in dastart()
3499 if ((softc->flags & DA_FLAG_RETRY_UA) != 0) { in dastart()
3500 start_ccb->ccb_h.ccb_state |= DA_CCB_RETRY_UA; in dastart()
3501 softc->flags &= ~DA_FLAG_RETRY_UA; in dastart()
3504 start_ccb->ccb_h.ccb_bp = bp; in dastart()
3505 softc->refcount++; in dastart()
3519 if (da_disable_wp_detection || softc->mode_page < 0) { in dastart()
3520 if ((softc->flags & DA_FLAG_CAN_RC16) != 0) in dastart()
3521 softc->state = DA_STATE_PROBE_RC16; in dastart()
3523 softc->state = DA_STATE_PROBE_RC; in dastart()
3529 xpt_print(periph->path, "Unable to send mode sense - " in dastart()
3531 if ((softc->flags & DA_FLAG_CAN_RC16) != 0) in dastart()
3532 softc->state = DA_STATE_PROBE_RC16; in dastart()
3534 softc->state = DA_STATE_PROBE_RC; in dastart()
3537 scsi_mode_sense_len(&start_ccb->csio, in dastart()
3543 /*page*/ softc->mode_page, in dastart()
3546 /*minimum_cmd_size*/ softc->minimum_cmd_size, in dastart()
3549 start_ccb->ccb_h.ccb_bp = NULL; in dastart()
3550 start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_WP; in dastart()
3565 scsi_read_capacity(&start_ccb->csio, in dastart()
3572 start_ccb->ccb_h.ccb_bp = NULL; in dastart()
3573 start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_RC; in dastart()
3588 scsi_read_capacity_16(&start_ccb->csio, in dastart()
3599 start_ccb->ccb_h.ccb_bp = NULL; in dastart()
3600 start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_RC16; in dastart()
3610 * If we get here we don't support any SBC-3 delete in dastart()
3613 * support it according to T10/1799-D Revision 31 in dastart()
3618 softc->state = DA_STATE_PROBE_BLK_LIMITS; in dastart()
3631 scsi_inquiry(&start_ccb->csio, in dastart()
3641 start_ccb->ccb_h.ccb_bp = NULL; in dastart()
3642 start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_LBP; in dastart()
3652 softc->state = DA_STATE_PROBE_BDC; in dastart()
3665 scsi_inquiry(&start_ccb->csio, in dastart()
3675 start_ccb->ccb_h.ccb_bp = NULL; in dastart()
3676 start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_BLK_LIMITS; in dastart()
3685 softc->state = DA_STATE_PROBE_ATA; in dastart()
3698 scsi_inquiry(&start_ccb->csio, in dastart()
3708 start_ccb->ccb_h.ccb_bp = NULL; in dastart()
3709 start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_BDC; in dastart()
3718 if ((softc->zone_mode == DA_ZONE_HOST_AWARE) in dastart()
3719 || (softc->zone_mode == DA_ZONE_HOST_MANAGED)) { in dastart()
3727 softc->state = DA_STATE_PROBE_ZONE; in dastart()
3734 ata_params = &periph->path->device->ident_data; in dastart()
3736 scsi_ata_identify(&start_ccb->csio, in dastart()
3744 start_ccb->ccb_h.ccb_bp = NULL; in dastart()
3745 start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_ATA; in dastart()
3756 if ((softc->flags & DA_FLAG_CAN_ATA_LOG) == 0) { in dastart()
3773 xpt_print(periph->path, "Couldn't malloc log_dir " in dastart()
3779 retval = scsi_ata_read_log(&start_ccb->csio, in dastart()
3786 /*protocol*/ softc->flags & DA_FLAG_CAN_ATA_DMA ? in dastart()
3794 xpt_print(periph->path, "scsi_ata_read_log() failed!"); in dastart()
3799 start_ccb->ccb_h.ccb_bp = NULL; in dastart()
3800 start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_ATA_LOGDIR; in dastart()
3816 if ((softc->flags & DA_FLAG_CAN_ATA_IDLOG) == 0) { in dastart()
3823 xpt_print(periph->path, "Couldn't malloc id_dir " in dastart()
3829 retval = scsi_ata_read_log(&start_ccb->csio, in dastart()
3836 /*protocol*/ softc->flags & DA_FLAG_CAN_ATA_DMA ? in dastart()
3844 xpt_print(periph->path, "scsi_ata_read_log() failed!"); in dastart()
3849 start_ccb->ccb_h.ccb_bp = NULL; in dastart()
3850 start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_ATA_IDDIR; in dastart()
3865 if ((softc->flags & DA_FLAG_CAN_ATA_SUPCAP) == 0) { in dastart()
3872 xpt_print(periph->path, "Couldn't malloc sup_cap " in dastart()
3878 retval = scsi_ata_read_log(&start_ccb->csio, in dastart()
3885 /*protocol*/ softc->flags & DA_FLAG_CAN_ATA_DMA ? in dastart()
3893 xpt_print(periph->path, "scsi_ata_read_log() failed!"); in dastart()
3899 start_ccb->ccb_h.ccb_bp = NULL; in dastart()
3900 start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_ATA_SUP; in dastart()
3913 * page is supported. If so, continue on to request it. in dastart()
3916 if ((softc->flags & DA_FLAG_CAN_ATA_ZONE) == 0) { in dastart()
3923 xpt_print(periph->path, "Couldn't malloc ata_zone " in dastart()
3929 retval = scsi_ata_read_log(&start_ccb->csio, in dastart()
3936 /*protocol*/ softc->flags & DA_FLAG_CAN_ATA_DMA ? in dastart()
3944 xpt_print(periph->path, "scsi_ata_read_log() failed!"); in dastart()
3949 start_ccb->ccb_h.ccb_bp = NULL; in dastart()
3950 start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_ATA_ZONE; in dastart()
3975 xpt_print(periph->path, "Couldn't malloc zone VPD " in dastart()
3979 scsi_inquiry(&start_ccb->csio, in dastart()
3989 start_ccb->ccb_h.ccb_bp = NULL; in dastart()
3990 start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_ZONE; in dastart()
4011 struct da_softc *softc = (struct da_softc *)periph->softc; in da_delete_unmap()
4013 uint8_t *buf = softc->unmap_buf; in da_delete_unmap()
4015 uint64_t lba, lastlba = (uint64_t)-1; in da_delete_unmap()
4030 bzero(softc->unmap_buf, sizeof(softc->unmap_buf)); in da_delete_unmap()
4039 * delete_run_queue in dadone, and relies on the biodone in da_delete_unmap()
4044 bioq_insert_tail(&softc->delete_run_queue, bp1); in da_delete_unmap()
4045 lba = bp1->bio_pblkno; in da_delete_unmap()
4046 count = bp1->bio_bcount / softc->params.secsize; in da_delete_unmap()
4050 c = omin(count, UNMAP_RANGE_MAX - lastcount); in da_delete_unmap()
4053 scsi_ulto4b(lastcount, d[ranges - 1].length); in da_delete_unmap()
4054 count -= c; in da_delete_unmap()
4057 } else if ((softc->quirks & DA_Q_STRICT_UNMAP) && in da_delete_unmap()
4058 softc->unmap_gran != 0) { in da_delete_unmap()
4060 if ((c = lastcount % softc->unmap_gran) != 0) { in da_delete_unmap()
4062 totalcount -= lastcount; in da_delete_unmap()
4063 lastlba = (uint64_t)-1; in da_delete_unmap()
4065 ranges--; in da_delete_unmap()
4067 totalcount -= c; in da_delete_unmap()
4068 lastlba -= c; in da_delete_unmap()
4069 lastcount -= c; in da_delete_unmap()
4071 d[ranges - 1].length); in da_delete_unmap()
4075 c = (lba - softc->unmap_gran_align) % softc->unmap_gran; in da_delete_unmap()
4077 c = softc->unmap_gran - c; in da_delete_unmap()
4082 count -= c; in da_delete_unmap()
4089 if (totalcount + c > softc->unmap_max_lba || in da_delete_unmap()
4090 ranges >= softc->unmap_max_ranges) { in da_delete_unmap()
4091 xpt_print(periph->path, in da_delete_unmap()
4094 da_delete_method_desc[softc->delete_method], in da_delete_unmap()
4095 totalcount + c, softc->unmap_max_lba, in da_delete_unmap()
4096 ranges, softc->unmap_max_ranges); in da_delete_unmap()
4104 count -= c; in da_delete_unmap()
4108 bp1 = cam_iosched_next_trim(softc->cam_iosched); in da_delete_unmap()
4111 if (ranges >= softc->unmap_max_ranges || in da_delete_unmap()
4112 totalcount + bp1->bio_bcount / in da_delete_unmap()
4113 softc->params.secsize > softc->unmap_max_lba) { in da_delete_unmap()
4114 cam_iosched_put_back_trim(softc->cam_iosched, bp1); in da_delete_unmap()
4120 if ((softc->quirks & DA_Q_STRICT_UNMAP) && softc->unmap_gran != 0 && in da_delete_unmap()
4121 (c = lastcount % softc->unmap_gran) != 0) { in da_delete_unmap()
4123 ranges--; in da_delete_unmap()
4125 scsi_ulto4b(lastcount - c, d[ranges - 1].length); in da_delete_unmap()
4131 scsi_unmap(&ccb->csio, in da_delete_unmap()
4140 ccb->ccb_h.ccb_state = DA_CCB_DELETE; in da_delete_unmap()
4141 ccb->ccb_h.flags |= CAM_UNLOCKED; in da_delete_unmap()
4142 softc->trim_count++; in da_delete_unmap()
4143 softc->trim_ranges += ranges; in da_delete_unmap()
4144 softc->trim_lbas += totalcount; in da_delete_unmap()
4145 cam_iosched_submit_trim(softc->cam_iosched); in da_delete_unmap()
4151 struct da_softc *softc = (struct da_softc *)periph->softc; in da_delete_trim()
4153 uint8_t *buf = softc->unmap_buf; in da_delete_trim()
4154 uint64_t lastlba = (uint64_t)-1; in da_delete_trim()
4160 bzero(softc->unmap_buf, sizeof(softc->unmap_buf)); in da_delete_trim()
4164 bioq_insert_tail(&softc->delete_run_queue, bp1); in da_delete_trim()
4165 lba = bp1->bio_pblkno; in da_delete_trim()
4166 count = bp1->bio_bcount / softc->params.secsize; in da_delete_trim()
4171 c = omin(count, ATA_DSM_RANGE_MAX - lastcount); in da_delete_trim()
4173 off = (ranges - 1) * 8; in da_delete_trim()
4176 count -= c; in da_delete_trim()
4194 count -= c; in da_delete_trim()
4196 if (count != 0 && ranges == softc->trim_max_ranges) { in da_delete_trim()
4197 xpt_print(periph->path, in da_delete_trim()
4199 da_delete_method_desc[softc->delete_method], in da_delete_trim()
4201 (softc->trim_max_ranges - ranges) * in da_delete_trim()
4207 bp1 = cam_iosched_next_trim(softc->cam_iosched); in da_delete_trim()
4210 if (bp1->bio_bcount / softc->params.secsize > in da_delete_trim()
4211 (softc->trim_max_ranges - ranges) * ATA_DSM_RANGE_MAX) { in da_delete_trim()
4212 cam_iosched_put_back_trim(softc->cam_iosched, bp1); in da_delete_trim()
4218 scsi_ata_trim(&ccb->csio, in da_delete_trim()
4227 ccb->ccb_h.ccb_state = DA_CCB_DELETE; in da_delete_trim()
4228 ccb->ccb_h.flags |= CAM_UNLOCKED; in da_delete_trim()
4229 softc->trim_count++; in da_delete_trim()
4230 softc->trim_ranges += ranges; in da_delete_trim()
4231 softc->trim_lbas += block_count; in da_delete_trim()
4232 cam_iosched_submit_trim(softc->cam_iosched); in da_delete_trim()
4237 * of using softc->ws_max_blks as it is absolute max for the
4249 softc = (struct da_softc *)periph->softc; in da_delete_ws()
4250 ws_max_blks = softc->disk->d_delmaxsize / softc->params.secsize; in da_delete_ws()
4251 lba = bp->bio_pblkno; in da_delete_ws()
4256 bioq_insert_tail(&softc->delete_run_queue, bp1); in da_delete_ws()
4257 count += bp1->bio_bcount / softc->params.secsize; in da_delete_ws()
4259 xpt_print(periph->path, in da_delete_ws()
4261 da_delete_method_desc[softc->delete_method], in da_delete_ws()
4266 bp1 = cam_iosched_next_trim(softc->cam_iosched); in da_delete_ws()
4269 if (lba + count != bp1->bio_pblkno || in da_delete_ws()
4270 count + bp1->bio_bcount / in da_delete_ws()
4271 softc->params.secsize > ws_max_blks) { in da_delete_ws()
4272 cam_iosched_put_back_trim(softc->cam_iosched, bp1); in da_delete_ws()
4277 scsi_write_same(&ccb->csio, in da_delete_ws()
4281 /*byte2*/softc->delete_method == in da_delete_ws()
4283 softc->delete_method == DA_DELETE_WS16 ? 16 : 10, in da_delete_ws()
4287 /*dxfer_len*/ softc->params.secsize, in da_delete_ws()
4290 ccb->ccb_h.ccb_state = DA_CCB_DELETE; in da_delete_ws()
4291 ccb->ccb_h.flags |= CAM_UNLOCKED; in da_delete_ws()
4292 softc->trim_count++; in da_delete_ws()
4293 softc->trim_ranges++; in da_delete_ws()
4294 softc->trim_lbas += count; in da_delete_ws()
4295 cam_iosched_submit_trim(softc->cam_iosched); in da_delete_ws()
4308 cdb = ccb->csio.cdb_io.cdb_bytes; in cmd6workaround()
4309 softc = (struct da_softc *)xpt_path_periph(ccb->ccb_h.path)->softc; in cmd6workaround()
4311 if (ccb->ccb_h.ccb_state == DA_CCB_DELETE) { in cmd6workaround()
4312 da_delete_methods old_method = softc->delete_method; in cmd6workaround()
4328 if (softc->delete_method == DA_DELETE_DISABLE) in cmd6workaround()
4329 xpt_print(ccb->ccb_h.path, in cmd6workaround()
4333 xpt_print(ccb->ccb_h.path, in cmd6workaround()
4336 da_delete_method_desc[softc->delete_method]); in cmd6workaround()
4338 while ((bp = bioq_takefirst(&softc->delete_run_queue)) != NULL) in cmd6workaround()
4339 cam_iosched_queue_work(softc->cam_iosched, bp); in cmd6workaround()
4340 cam_iosched_queue_work(softc->cam_iosched, in cmd6workaround()
4341 (struct bio *)ccb->ccb_h.ccb_bp); in cmd6workaround()
4342 ccb->ccb_h.ccb_bp = NULL; in cmd6workaround()
4347 if ((ccb->ccb_h.flags & CAM_CDB_POINTER) == 0 && in cmd6workaround()
4349 (softc->quirks & DA_Q_NO_PREVENT) == 0) { in cmd6workaround()
4351 xpt_print(ccb->ccb_h.path, in cmd6workaround()
4353 softc->quirks |= DA_Q_NO_PREVENT; in cmd6workaround()
4358 if ((ccb->ccb_h.flags & CAM_CDB_POINTER) == 0 && in cmd6workaround()
4360 (softc->quirks & DA_Q_NO_SYNC_CACHE) == 0) { in cmd6workaround()
4362 xpt_print(ccb->ccb_h.path, in cmd6workaround()
4364 softc->quirks |= DA_Q_NO_SYNC_CACHE; in cmd6workaround()
4365 softc->disk->d_flags &= ~DISKFLAG_CANFLUSHCACHE; in cmd6workaround()
4370 if ((ccb->ccb_h.flags & CAM_CDB_POINTER) != 0 || in cmd6workaround()
4374 xpt_print(ccb->ccb_h.path, "READ(6)/WRITE(6) not supported, " in cmd6workaround()
4376 softc->minimum_cmd_size = 10; in cmd6workaround()
4380 cmd10->opcode = (cmd6.opcode == READ_6) ? READ_10 : WRITE_10; in cmd6workaround()
4381 cmd10->byte2 = 0; in cmd6workaround()
4382 scsi_ulto4b(scsi_3btoul(cmd6.addr), cmd10->addr); in cmd6workaround()
4383 cmd10->reserved = 0; in cmd6workaround()
4384 scsi_ulto2b(cmd6.length, cmd10->length); in cmd6workaround()
4385 cmd10->control = cmd6.control; in cmd6workaround()
4386 ccb->csio.cdb_len = sizeof(*cmd10); in cmd6workaround()
4389 frozen = (ccb->ccb_h.status & CAM_DEV_QFRZN) != 0; in cmd6workaround()
4390 ccb->ccb_h.status = CAM_REQUEUE_REQ; in cmd6workaround()
4393 cam_release_devq(ccb->ccb_h.path, in cmd6workaround()
4408 softc = periph->softc; in dazonedone()
4409 bp = (struct bio *)ccb->ccb_h.ccb_bp; in dazonedone()
4411 switch (bp->bio_zone.zone_cmd) { in dazonedone()
4427 rep = &bp->bio_zone.zone_params.report; in dazonedone()
4428 avail_len = ccb->csio.dxfer_len - ccb->csio.resid; in dazonedone()
4439 bp->bio_resid = ccb->csio.resid; in dazonedone()
4440 hdr = (struct scsi_report_zones_hdr *)ccb->csio.data_ptr; in dazonedone()
4447 bp->bio_error = EIO; in dazonedone()
4448 bp->bio_flags |= BIO_ERROR; in dazonedone()
4449 bp->bio_resid = bp->bio_bcount; in dazonedone()
4453 if (softc->zone_interface == DA_ZONE_IF_ATA_PASS) in dazonedone()
4458 hdr_len = ata ? le32dec(hdr->length) : in dazonedone()
4459 scsi_4btoul(hdr->length); in dazonedone()
4461 rep->entries_available = hdr_len / sizeof(*desc); in dazonedone()
4463 rep->entries_available = 0; in dazonedone()
4470 rep->header.same = hdr->byte4 & SRZ_SAME_MASK; in dazonedone()
4471 rep->header.maximum_lba = ata ? le64dec(hdr->maximum_lba) : in dazonedone()
4472 scsi_8btou64(hdr->maximum_lba); in dazonedone()
4478 rep->entries_filled = 0; in dazonedone()
4482 num_avail = min((avail_len - sizeof(*hdr)) / sizeof(*desc), in dazonedone()
4488 rep->entries_filled = 0; in dazonedone()
4492 num_to_fill = min(num_avail, rep->entries_allocated); in dazonedone()
4498 rep->entries_filled = 0; in dazonedone()
4502 for (i = 0, desc = &hdr->desc_list[0], entry=&rep->entries[0]; in dazonedone()
4513 entry->zone_type = desc->zone_type & SRZ_TYPE_MASK; in dazonedone()
4514 entry->zone_condition = in dazonedone()
4515 (desc->zone_flags & SRZ_ZONE_COND_MASK) >> in dazonedone()
4517 entry->zone_flags |= desc->zone_flags & in dazonedone()
4519 entry->zone_length = in dazonedone()
4520 ata ? le64dec(desc->zone_length) : in dazonedone()
4521 scsi_8btou64(desc->zone_length); in dazonedone()
4522 entry->zone_start_lba = in dazonedone()
4523 ata ? le64dec(desc->zone_start_lba) : in dazonedone()
4524 scsi_8btou64(desc->zone_start_lba); in dazonedone()
4525 entry->write_pointer_lba = in dazonedone()
4526 ata ? le64dec(desc->write_pointer_lba) : in dazonedone()
4527 scsi_8btou64(desc->write_pointer_lba); in dazonedone()
4529 rep->entries_filled = num_to_fill; in dazonedone()
4540 bp->bio_zone.zone_cmd); in dazonedone()
4544 if (bp->bio_zone.zone_cmd == DISK_ZONE_REPORT_ZONES) in dazonedone()
4545 free(ccb->csio.data_ptr, M_SCSIDA); in dazonedone()
4556 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone\n")); in dadone()
4558 softc = (struct da_softc *)periph->softc; in dadone()
4559 csio = &done_ccb->csio; in dadone()
4562 if (csio->bio != NULL) in dadone()
4563 biotrack(csio->bio, __func__); in dadone()
4565 state = csio->ccb_h.ccb_state & DA_CCB_TYPE_MASK; in dadone()
4568 bp = (struct bio *)done_ccb->ccb_h.ccb_bp; in dadone()
4569 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { in dadone()
4573 if ((csio->ccb_h.ccb_state & DA_CCB_RETRY_UA) != 0) in dadone()
4584 bp = (struct bio *)done_ccb->ccb_h.ccb_bp; in dadone()
4596 && (softc->flags & DA_FLAG_PACK_INVALID)== 0) { in dadone()
4604 xpt_print(periph->path, "Invalidating pack\n"); in dadone()
4605 softc->flags |= DA_FLAG_PACK_INVALID; in dadone()
4607 softc->invalidations++; in dadone()
4611 cam_iosched_flush(softc->cam_iosched, NULL, in dadone()
4614 bp->bio_error = error; in dadone()
4615 bp->bio_resid = bp->bio_bcount; in dadone()
4616 bp->bio_flags |= BIO_ERROR; in dadone()
4620 bp->bio_resid = 0; in dadone()
4622 bp->bio_resid = csio->resid; in dadone()
4623 bp->bio_error = 0; in dadone()
4624 if (bp->bio_resid != 0) in dadone()
4625 bp->bio_flags |= BIO_ERROR; in dadone()
4627 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) in dadone()
4628 cam_release_devq(done_ccb->ccb_h.path, in dadone()
4634 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) in dadone()
4636 if (bp->bio_cmd == BIO_ZONE) in dadone()
4639 bp->bio_resid = 0; in dadone()
4641 bp->bio_resid = csio->resid; in dadone()
4642 if ((csio->resid > 0) && (bp->bio_cmd != BIO_ZONE)) in dadone()
4643 bp->bio_flags |= BIO_ERROR; in dadone()
4644 if (softc->error_inject != 0) { in dadone()
4645 bp->bio_error = softc->error_inject; in dadone()
4646 bp->bio_resid = bp->bio_bcount; in dadone()
4647 bp->bio_flags |= BIO_ERROR; in dadone()
4648 softc->error_inject = 0; in dadone()
4654 LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); in dadone()
4655 if (LIST_EMPTY(&softc->pending_ccbs)) in dadone()
4656 softc->flags |= DA_FLAG_WAS_OTAG; in dadone()
4664 cam_iosched_bio_complete(softc->cam_iosched, bp, done_ccb); in dadone()
4666 KASSERT(softc->refcount >= 1, ("dadone softc %p refcount %d", softc, softc->refcount)); in dadone()
4667 softc->refcount--; in dadone()
4672 TAILQ_CONCAT(&queue, &softc->delete_run_queue.queue, bio_queue); in dadone()
4673 softc->delete_run_queue.insert_point = NULL; in dadone()
4684 cam_iosched_trim_done(softc->cam_iosched); in dadone()
4689 bp1->bio_error = bp->bio_error; in dadone()
4690 if (bp->bio_flags & BIO_ERROR) { in dadone()
4691 bp1->bio_flags |= BIO_ERROR; in dadone()
4692 bp1->bio_resid = bp1->bio_bcount; in dadone()
4694 bp1->bio_resid = 0; in dadone()
4713 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_probewp\n")); in dadone_probewp()
4715 softc = (struct da_softc *)periph->softc; in dadone_probewp()
4716 priority = done_ccb->ccb_h.pinfo.priority; in dadone_probewp()
4717 csio = &done_ccb->csio; in dadone_probewp()
4721 KASSERT(softc->state == DA_STATE_PROBE_WP, in dadone_probewp()
4723 softc->state, periph, done_ccb)); in dadone_probewp()
4724 KASSERT((csio->ccb_h.ccb_state & DA_CCB_TYPE_MASK) == DA_CCB_PROBE_WP, in dadone_probewp()
4726 (unsigned long)csio->ccb_h.ccb_state & DA_CCB_TYPE_MASK, periph, in dadone_probewp()
4733 if (csio->cdb_len > 6) { in dadone_probewp()
4735 (struct scsi_mode_header_10 *)csio->data_ptr; in dadone_probewp()
4736 len = 2 + scsi_2btoul(mh->data_length); in dadone_probewp()
4737 off = sizeof(*mh) + scsi_2btoul(mh->blk_desc_len); in dadone_probewp()
4738 dev_spec = mh->dev_spec; in dadone_probewp()
4741 (struct scsi_mode_header_6 *)csio->data_ptr; in dadone_probewp()
4742 len = 1 + mh->data_length; in dadone_probewp()
4743 off = sizeof(*mh) + mh->blk_desc_len; in dadone_probewp()
4744 dev_spec = mh->dev_spec; in dadone_probewp()
4747 softc->disk->d_flags |= DISKFLAG_WRITE_PROTECT; in dadone_probewp()
4749 softc->disk->d_flags &= ~DISKFLAG_WRITE_PROTECT; in dadone_probewp()
4752 if (off < len && off < csio->dxfer_len - csio->resid) in dadone_probewp()
4753 softc->mode_page = csio->data_ptr[off] & SMPH_PC_MASK; in dadone_probewp()
4762 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { in dadone_probewp()
4764 cam_release_devq(done_ccb->ccb_h.path, in dadone_probewp()
4771 /* We don't depend on it, so don't try again. */ in dadone_probewp()
4772 softc->mode_page = -1; in dadone_probewp()
4776 free(csio->data_ptr, M_SCSIDA); in dadone_probewp()
4777 if ((softc->flags & DA_FLAG_CAN_RC16) != 0) in dadone_probewp()
4778 softc->state = DA_STATE_PROBE_RC16; in dadone_probewp()
4780 softc->state = DA_STATE_PROBE_RC; in dadone_probewp()
4798 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_proberc\n")); in dadone_proberc()
4800 softc = (struct da_softc *)periph->softc; in dadone_proberc()
4801 priority = done_ccb->ccb_h.pinfo.priority; in dadone_proberc()
4802 csio = &done_ccb->csio; in dadone_proberc()
4803 state = csio->ccb_h.ccb_state & DA_CCB_TYPE_MASK; in dadone_proberc()
4805 KASSERT(softc->state == DA_STATE_PROBE_RC || softc->state == DA_STATE_PROBE_RC16, in dadone_proberc()
4807 softc->state, periph, done_ccb)); in dadone_proberc()
4816 announce_buf = softc->announce_temp; in dadone_proberc()
4820 rdcap =(struct scsi_read_capacity_data *)csio->data_ptr; in dadone_proberc()
4823 csio->data_ptr; in dadone_proberc()
4827 if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in dadone_proberc()
4834 block_size = scsi_4btoul(rdcap->length); in dadone_proberc()
4835 maxsector = scsi_4btoul(rdcap->addr); in dadone_proberc()
4839 * According to SBC-2, if the standard 10 in dadone_proberc()
4848 softc->state = DA_STATE_PROBE_RC16; in dadone_proberc()
4854 block_size = scsi_4btoul(rcaplong->length); in dadone_proberc()
4855 maxsector = scsi_8btou64(rcaplong->addr); in dadone_proberc()
4856 lalba = scsi_2btoul(rcaplong->lalba_lbp); in dadone_proberc()
4867 maxsector = -1; in dadone_proberc()
4870 xpt_print(periph->path, in dadone_proberc()
4879 * non-NULL. in dadone_proberc()
4884 dp = &softc->params; in dadone_proberc()
4887 ((uintmax_t)dp->secsize * dp->sectors) / in dadone_proberc()
4889 (uintmax_t)dp->sectors, dp->secsize); in dadone_proberc()
4890 if (softc->p_type != 0) { in dadone_proberc()
4892 DA_ANNOUNCETMP_SZ - n, in dadone_proberc()
4893 ", DIF type %d", softc->p_type); in dadone_proberc()
4895 snprintf(announce_buf + n, DA_ANNOUNCETMP_SZ - n, ")"); in dadone_proberc()
4920 status = done_ccb->ccb_h.status; in dadone_proberc()
4922 cam_release_devq(done_ccb->ccb_h.path, in dadone_proberc()
4929 xpt_setup_ccb(&cgd.ccb_h, done_ccb->ccb_h.path, in dadone_proberc()
4945 (softc->flags & DA_FLAG_CAN_RC16) && in dadone_proberc()
4946 (((csio->ccb_h.status & CAM_STATUS_MASK) == in dadone_proberc()
4953 softc->flags &= ~DA_FLAG_CAN_RC16; in dadone_proberc()
4955 softc->state = DA_STATE_PROBE_RC; in dadone_proberc()
4982 dasetgeom(periph, 512, -1, NULL, 0); in dadone_proberc()
4992 scsi_sense_print(&done_ccb->csio); in dadone_proberc()
4994 xpt_print(periph->path, in dadone_proberc()
4996 done_ccb->ccb_h.status); in dadone_proberc()
4999 xpt_print(periph->path, "fatal error, " in dadone_proberc()
5011 free(csio->data_ptr, M_SCSIDA); in dadone_proberc()
5013 ((softc->flags & DA_FLAG_ANNOUNCED) == 0)) { in dadone_proberc()
5016 sbuf_new(&sb, softc->announcebuf, DA_ANNOUNCE_SZ, in dadone_proberc()
5019 xpt_announce_quirks_sbuf(periph, &sb, softc->quirks, in dadone_proberc()
5031 &softc->sysctl_task); in dadone_proberc()
5034 xpt_print(periph->path, "fatal error, " in dadone_proberc()
5040 if (softc->flags & DA_FLAG_PROBED) { in dadone_proberc()
5045 /* Ensure re-probe doesn't see old delete. */ in dadone_proberc()
5046 softc->delete_available = 0; in dadone_proberc()
5048 if (lbp && (softc->quirks & DA_Q_NO_UNMAP) == 0) { in dadone_proberc()
5050 * Based on older SBC-3 spec revisions in dadone_proberc()
5066 softc->state = DA_STATE_PROBE_LBP; in dadone_proberc()
5072 softc->state = DA_STATE_PROBE_BDC; in dadone_proberc()
5086 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_probelbp\n")); in dadone_probelbp()
5088 softc = (struct da_softc *)periph->softc; in dadone_probelbp()
5089 priority = done_ccb->ccb_h.pinfo.priority; in dadone_probelbp()
5090 csio = &done_ccb->csio; in dadone_probelbp()
5091 lbp = (struct scsi_vpd_logical_block_prov *)csio->data_ptr; in dadone_probelbp()
5095 if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in dadone_probelbp()
5097 * T10/1799-D Revision 31 states at least one of these in dadone_probelbp()
5101 (lbp->flags & SVPD_LBP_WS16)); in dadone_probelbp()
5103 (lbp->flags & SVPD_LBP_WS10)); in dadone_probelbp()
5105 (lbp->flags & SVPD_LBP_UNMAP)); in dadone_probelbp()
5113 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { in dadone_probelbp()
5115 cam_release_devq(done_ccb->ccb_h.path, in dadone_probelbp()
5123 * Failure indicates we don't support any SBC-3 in dadone_probelbp()
5130 softc->state = DA_STATE_PROBE_BLK_LIMITS; in dadone_probelbp()
5144 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_probeblklimits\n")); in dadone_probeblklimits()
5146 softc = (struct da_softc *)periph->softc; in dadone_probeblklimits()
5147 priority = done_ccb->ccb_h.pinfo.priority; in dadone_probeblklimits()
5148 csio = &done_ccb->csio; in dadone_probeblklimits()
5149 block_limits = (struct scsi_vpd_block_limits *)csio->data_ptr; in dadone_probeblklimits()
5153 if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in dadone_probeblklimits()
5155 block_limits->max_txfer_len); in dadone_probeblklimits()
5157 block_limits->max_unmap_lba_cnt); in dadone_probeblklimits()
5159 block_limits->max_unmap_blk_cnt); in dadone_probeblklimits()
5161 block_limits->opt_unmap_grain); in dadone_probeblklimits()
5163 block_limits->unmap_grain_align); in dadone_probeblklimits()
5165 block_limits->max_write_same_length); in dadone_probeblklimits()
5168 softc->disk->d_maxsize = MIN(softc->maxio, in dadone_probeblklimits()
5169 (off_t)max_txfer_len * softc->params.secsize); in dadone_probeblklimits()
5178 softc->unmap_max_lba = max_unmap_lba_cnt; in dadone_probeblklimits()
5179 softc->unmap_max_ranges = min(max_unmap_blk_cnt, in dadone_probeblklimits()
5182 softc->unmap_gran = unmap_gran; in dadone_probeblklimits()
5184 softc->unmap_gran_align = in dadone_probeblklimits()
5197 softc->ws_max_blks = ws_max_blks; in dadone_probeblklimits()
5205 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { in dadone_probeblklimits()
5207 cam_release_devq(done_ccb->ccb_h.path, in dadone_probeblklimits()
5218 softc->unmap_max_lba = 1; in dadone_probeblklimits()
5219 softc->unmap_max_ranges = 1; in dadone_probeblklimits()
5224 softc->state = DA_STATE_PROBE_BDC; in dadone_probeblklimits()
5238 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_probebdc\n")); in dadone_probebdc()
5240 softc = (struct da_softc *)periph->softc; in dadone_probebdc()
5241 priority = done_ccb->ccb_h.pinfo.priority; in dadone_probebdc()
5242 csio = &done_ccb->csio; in dadone_probebdc()
5243 bdc = (struct scsi_vpd_block_device_characteristics *)csio->data_ptr; in dadone_probebdc()
5247 if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in dadone_probebdc()
5251 * Disable queue sorting for non-rotational media in dadone_probebdc()
5254 uint16_t old_rate = softc->disk->d_rotation_rate; in dadone_probebdc()
5256 valid_len = csio->dxfer_len - csio->resid; in dadone_probebdc()
5259 softc->disk->d_rotation_rate = in dadone_probebdc()
5260 scsi_2btoul(bdc->medium_rotation_rate); in dadone_probebdc()
5261 if (softc->disk->d_rotation_rate == SVPD_NON_ROTATING) { in dadone_probebdc()
5263 softc->cam_iosched, 0); in dadone_probebdc()
5264 softc->flags &= ~DA_FLAG_ROTATING; in dadone_probebdc()
5266 if (softc->disk->d_rotation_rate != old_rate) { in dadone_probebdc()
5267 disk_attr_changed(softc->disk, in dadone_probebdc()
5272 && (softc->zone_mode == DA_ZONE_NONE)) { in dadone_probebdc()
5288 if ((bdc->flags & SVPD_ZBC_MASK) == in dadone_probebdc()
5290 softc->zone_mode = DA_ZONE_HOST_AWARE; in dadone_probebdc()
5291 softc->zone_interface = (ata_proto) ? in dadone_probebdc()
5293 } else if ((bdc->flags & SVPD_ZBC_MASK) == in dadone_probebdc()
5295 softc->zone_mode =DA_ZONE_DRIVE_MANAGED; in dadone_probebdc()
5296 softc->zone_interface = (ata_proto) ? in dadone_probebdc()
5298 } else if ((bdc->flags & SVPD_ZBC_MASK) != in dadone_probebdc()
5300 xpt_print(periph->path, "Unknown zoned " in dadone_probebdc()
5302 bdc->flags & SVPD_ZBC_MASK); in dadone_probebdc()
5312 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { in dadone_probebdc()
5314 cam_release_devq(done_ccb->ccb_h.path, in dadone_probebdc()
5324 softc->state = DA_STATE_PROBE_ATA; in dadone_probebdc()
5340 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_probeata\n")); in dadone_probeata()
5342 softc = (struct da_softc *)periph->softc; in dadone_probeata()
5343 priority = done_ccb->ccb_h.pinfo.priority; in dadone_probeata()
5344 csio = &done_ccb->csio; in dadone_probeata()
5345 ata_params = (struct ata_params *)csio->data_ptr; in dadone_probeata()
5351 if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in dadone_probeata()
5355 if (ata_params->support_dsm & ATA_SUPPORT_DSM_TRIM && in dadone_probeata()
5356 (softc->quirks & DA_Q_NO_UNMAP) == 0) { in dadone_probeata()
5358 if (ata_params->max_dsm_blocks != 0) in dadone_probeata()
5359 softc->trim_max_ranges = min( in dadone_probeata()
5360 softc->trim_max_ranges, in dadone_probeata()
5361 ata_params->max_dsm_blocks * in dadone_probeata()
5365 * Disable queue sorting for non-rotational media in dadone_probeata()
5368 old_rate = softc->disk->d_rotation_rate; in dadone_probeata()
5369 softc->disk->d_rotation_rate = ata_params->media_rotation_rate; in dadone_probeata()
5370 if (softc->disk->d_rotation_rate == ATA_RATE_NON_ROTATING) { in dadone_probeata()
5371 cam_iosched_set_sort_queue(softc->cam_iosched, 0); in dadone_probeata()
5372 softc->flags &= ~DA_FLAG_ROTATING; in dadone_probeata()
5374 if (softc->disk->d_rotation_rate != old_rate) { in dadone_probeata()
5375 disk_attr_changed(softc->disk, in dadone_probeata()
5380 if (ata_params->capabilities1 & ATA_SUPPORT_DMA) in dadone_probeata()
5381 softc->flags |= DA_FLAG_CAN_ATA_DMA; in dadone_probeata()
5383 if (ata_params->support.extension & ATA_SUPPORT_GENLOG) in dadone_probeata()
5384 softc->flags |= DA_FLAG_CAN_ATA_LOG; in dadone_probeata()
5389 * SAT layer supports ZBC -> ZAC translation. In in dadone_probeata()
5395 if (softc->zone_mode == DA_ZONE_NONE) { in dadone_probeata()
5407 if ((ata_params->support3 & in dadone_probeata()
5410 softc->zone_mode = DA_ZONE_HOST_AWARE; in dadone_probeata()
5411 softc->zone_interface = in dadone_probeata()
5413 } else if ((ata_params->support3 & in dadone_probeata()
5416 softc->zone_mode =DA_ZONE_DRIVE_MANAGED; in dadone_probeata()
5417 softc->zone_interface = DA_ZONE_IF_ATA_PASS; in dadone_probeata()
5427 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { in dadone_probeata()
5429 cam_release_devq(done_ccb->ccb_h.path, in dadone_probeata()
5438 if ((softc->zone_mode == DA_ZONE_HOST_AWARE) in dadone_probeata()
5439 || (softc->zone_mode == DA_ZONE_HOST_MANAGED)) { in dadone_probeata()
5446 * ZBC -> ZAC translation, continue on to get the in dadone_probeata()
5449 * ZBC -> ZAC translation, we want to use that, in dadone_probeata()
5454 && (softc->flags & DA_FLAG_CAN_ATA_LOG) in dadone_probeata()
5455 && (softc->zone_interface == DA_ZONE_IF_ATA_PASS)) in dadone_probeata()
5456 softc->state = DA_STATE_PROBE_ATA_LOGDIR; in dadone_probeata()
5458 softc->state = DA_STATE_PROBE_ZONE; in dadone_probeata()
5478 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_probeatalogdir\n")); in dadone_probeatalogdir()
5480 softc = (struct da_softc *)periph->softc; in dadone_probeatalogdir()
5481 priority = done_ccb->ccb_h.pinfo.priority; in dadone_probeatalogdir()
5482 csio = &done_ccb->csio; in dadone_probeatalogdir()
5485 if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in dadone_probeatalogdir()
5487 softc->valid_logdir_len = 0; in dadone_probeatalogdir()
5488 bzero(&softc->ata_logdir, sizeof(softc->ata_logdir)); in dadone_probeatalogdir()
5489 softc->valid_logdir_len = csio->dxfer_len - csio->resid; in dadone_probeatalogdir()
5490 if (softc->valid_logdir_len > 0) in dadone_probeatalogdir()
5491 bcopy(csio->data_ptr, &softc->ata_logdir, in dadone_probeatalogdir()
5492 min(softc->valid_logdir_len, in dadone_probeatalogdir()
5493 sizeof(softc->ata_logdir))); in dadone_probeatalogdir()
5501 if ((softc->valid_logdir_len >= in dadone_probeatalogdir()
5503 && (le16dec(softc->ata_logdir.header) == in dadone_probeatalogdir()
5505 && (le16dec(&softc->ata_logdir.num_pages[ in dadone_probeatalogdir()
5507 sizeof(uint16_t)) - sizeof(uint16_t)]) > 0)){ in dadone_probeatalogdir()
5508 softc->flags |= DA_FLAG_CAN_ATA_IDLOG; in dadone_probeatalogdir()
5510 softc->flags &= ~DA_FLAG_CAN_ATA_IDLOG; in dadone_probeatalogdir()
5524 softc->flags &= ~(DA_FLAG_CAN_ATA_LOG | in dadone_probeatalogdir()
5526 if ((done_ccb->ccb_h.status & in dadone_probeatalogdir()
5529 cam_release_devq(done_ccb->ccb_h.path, in dadone_probeatalogdir()
5538 free(csio->data_ptr, M_SCSIDA); in dadone_probeatalogdir()
5541 && (softc->flags & DA_FLAG_CAN_ATA_IDLOG)) { in dadone_probeatalogdir()
5542 softc->state = DA_STATE_PROBE_ATA_IDDIR; in dadone_probeatalogdir()
5559 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_probeataiddir\n")); in dadone_probeataiddir()
5561 softc = (struct da_softc *)periph->softc; in dadone_probeataiddir()
5562 priority = done_ccb->ccb_h.pinfo.priority; in dadone_probeataiddir()
5563 csio = &done_ccb->csio; in dadone_probeataiddir()
5567 if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in dadone_probeataiddir()
5571 softc->valid_iddir_len = 0; in dadone_probeataiddir()
5572 bzero(&softc->ata_iddir, sizeof(softc->ata_iddir)); in dadone_probeataiddir()
5573 softc->flags &= ~(DA_FLAG_CAN_ATA_SUPCAP | in dadone_probeataiddir()
5575 softc->valid_iddir_len = csio->dxfer_len - csio->resid; in dadone_probeataiddir()
5576 if (softc->valid_iddir_len > 0) in dadone_probeataiddir()
5577 bcopy(csio->data_ptr, &softc->ata_iddir, in dadone_probeataiddir()
5578 min(softc->valid_iddir_len, in dadone_probeataiddir()
5579 sizeof(softc->ata_iddir))); in dadone_probeataiddir()
5583 max_entries = softc->valid_iddir_len - entries_offset; in dadone_probeataiddir()
5584 if ((softc->valid_iddir_len > (entries_offset + 1)) in dadone_probeataiddir()
5585 && (le64dec(softc->ata_iddir.header) == ATA_IDLOG_REVISION) in dadone_probeataiddir()
5586 && (softc->ata_iddir.entry_count > 0)) { in dadone_probeataiddir()
5589 num_entries = softc->ata_iddir.entry_count; in dadone_probeataiddir()
5591 softc->valid_iddir_len - entries_offset); in dadone_probeataiddir()
5593 if (softc->ata_iddir.entries[i] == in dadone_probeataiddir()
5595 softc->flags |= DA_FLAG_CAN_ATA_SUPCAP; in dadone_probeataiddir()
5596 else if (softc->ata_iddir.entries[i] == in dadone_probeataiddir()
5598 softc->flags |= DA_FLAG_CAN_ATA_ZONE; in dadone_probeataiddir()
5600 if ((softc->flags & DA_FLAG_CAN_ATA_SUPCAP) in dadone_probeataiddir()
5601 && (softc->flags & DA_FLAG_CAN_ATA_ZONE)) in dadone_probeataiddir()
5615 * a non-zero number of pages present for in dadone_probeataiddir()
5618 softc->flags &= ~DA_FLAG_CAN_ATA_IDLOG; in dadone_probeataiddir()
5619 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { in dadone_probeataiddir()
5621 cam_release_devq(done_ccb->ccb_h.path, in dadone_probeataiddir()
5630 free(csio->data_ptr, M_SCSIDA); in dadone_probeataiddir()
5632 if ((error == 0) && (softc->flags & DA_FLAG_CAN_ATA_SUPCAP)) { in dadone_probeataiddir()
5633 softc->state = DA_STATE_PROBE_ATA_SUP; in dadone_probeataiddir()
5650 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_probeatasup\n")); in dadone_probeatasup()
5652 softc = (struct da_softc *)periph->softc; in dadone_probeatasup()
5653 priority = done_ccb->ccb_h.pinfo.priority; in dadone_probeatasup()
5654 csio = &done_ccb->csio; in dadone_probeatasup()
5658 if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in dadone_probeatasup()
5664 sup_cap = (struct ata_identify_log_sup_cap *)csio->data_ptr; in dadone_probeatasup()
5665 valid_len = csio->dxfer_len - csio->resid; in dadone_probeatasup()
5667 sup_zac_cap) + 1 + sizeof(sup_cap->sup_zac_cap); in dadone_probeatasup()
5671 zoned = le64dec(sup_cap->zoned_cap); in dadone_probeatasup()
5680 softc->zone_mode = DA_ZONE_HOST_AWARE; in dadone_probeatasup()
5683 softc->zone_mode = in dadone_probeatasup()
5687 zac_cap = le64dec(sup_cap->sup_zac_cap); in dadone_probeatasup()
5690 softc->zone_flags |= in dadone_probeatasup()
5693 softc->zone_flags |= in dadone_probeatasup()
5696 softc->zone_flags |= in dadone_probeatasup()
5699 softc->zone_flags |= in dadone_probeatasup()
5702 softc->zone_flags |= in dadone_probeatasup()
5707 * ACS-4, r08 on April 28th, 2015. in dadone_probeatasup()
5713 softc->zone_flags |= DA_ZONE_FLAG_SUP_MASK; in dadone_probeatasup()
5727 softc->flags &= ~DA_FLAG_CAN_ATA_SUPCAP; in dadone_probeatasup()
5731 softc->zone_flags &= ~DA_ZONE_FLAG_SUP_MASK; in dadone_probeatasup()
5732 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { in dadone_probeatasup()
5734 cam_release_devq(done_ccb->ccb_h.path, in dadone_probeatasup()
5743 free(csio->data_ptr, M_SCSIDA); in dadone_probeatasup()
5745 if ((error == 0) && (softc->flags & DA_FLAG_CAN_ATA_ZONE)) { in dadone_probeatasup()
5746 softc->state = DA_STATE_PROBE_ATA_ZONE; in dadone_probeatasup()
5762 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_probeatazone\n")); in dadone_probeatazone()
5764 softc = (struct da_softc *)periph->softc; in dadone_probeatazone()
5765 csio = &done_ccb->csio; in dadone_probeatazone()
5769 if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in dadone_probeatazone()
5774 zi_log = (struct ata_zoned_info_log *)csio->data_ptr; in dadone_probeatazone()
5776 valid_len = csio->dxfer_len - csio->resid; in dadone_probeatazone()
5778 version_info) + 1 + sizeof(zi_log->version_info); in dadone_probeatazone()
5782 tmpvar = le64dec(zi_log->zoned_cap); in dadone_probeatazone()
5785 softc->zone_flags |= in dadone_probeatazone()
5788 softc->zone_flags &= in dadone_probeatazone()
5791 tmpvar = le64dec(zi_log->optimal_seq_zones); in dadone_probeatazone()
5793 softc->zone_flags |= DA_ZONE_FLAG_OPT_SEQ_SET; in dadone_probeatazone()
5794 softc->optimal_seq_zones = (tmpvar & in dadone_probeatazone()
5797 softc->zone_flags &= ~DA_ZONE_FLAG_OPT_SEQ_SET; in dadone_probeatazone()
5798 softc->optimal_seq_zones = 0; in dadone_probeatazone()
5801 tmpvar =le64dec(zi_log->optimal_nonseq_zones); in dadone_probeatazone()
5803 softc->zone_flags |= in dadone_probeatazone()
5805 softc->optimal_nonseq_zones = in dadone_probeatazone()
5808 softc->zone_flags &= in dadone_probeatazone()
5810 softc->optimal_nonseq_zones = 0; in dadone_probeatazone()
5813 tmpvar = le64dec(zi_log->max_seq_req_zones); in dadone_probeatazone()
5815 softc->zone_flags |= DA_ZONE_FLAG_MAX_SEQ_SET; in dadone_probeatazone()
5816 softc->max_seq_zones = in dadone_probeatazone()
5819 softc->zone_flags &= ~DA_ZONE_FLAG_MAX_SEQ_SET; in dadone_probeatazone()
5820 softc->max_seq_zones = 0; in dadone_probeatazone()
5829 softc->flags &= ~DA_FLAG_CAN_ATA_ZONE; in dadone_probeatazone()
5830 softc->flags &= ~DA_ZONE_FLAG_SET_MASK; in dadone_probeatazone()
5832 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { in dadone_probeatazone()
5834 cam_release_devq(done_ccb->ccb_h.path, in dadone_probeatazone()
5843 free(csio->data_ptr, M_SCSIDA); in dadone_probeatazone()
5856 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_probezone\n")); in dadone_probezone()
5858 softc = (struct da_softc *)periph->softc; in dadone_probezone()
5859 csio = &done_ccb->csio; in dadone_probezone()
5863 if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in dadone_probezone()
5869 zoned_bdc = (struct scsi_vpd_zoned_bdc *)csio->data_ptr; in dadone_probezone()
5870 valid_len = csio->dxfer_len - csio->resid; in dadone_probezone()
5873 sizeof(zoned_bdc->max_seq_req_zones); in dadone_probezone()
5875 && (scsi_2btoul(zoned_bdc->page_length) >= SVPD_ZBDC_PL)) { in dadone_probezone()
5876 if (zoned_bdc->flags & SVPD_ZBDC_URSWRZ) in dadone_probezone()
5877 softc->zone_flags |= DA_ZONE_FLAG_URSWRZ; in dadone_probezone()
5879 softc->zone_flags &= ~DA_ZONE_FLAG_URSWRZ; in dadone_probezone()
5880 softc->optimal_seq_zones = in dadone_probezone()
5881 scsi_4btoul(zoned_bdc->optimal_seq_zones); in dadone_probezone()
5882 softc->zone_flags |= DA_ZONE_FLAG_OPT_SEQ_SET; in dadone_probezone()
5883 softc->optimal_nonseq_zones = scsi_4btoul( in dadone_probezone()
5884 zoned_bdc->optimal_nonseq_zones); in dadone_probezone()
5885 softc->zone_flags |= DA_ZONE_FLAG_OPT_NONSEQ_SET; in dadone_probezone()
5886 softc->max_seq_zones = in dadone_probezone()
5887 scsi_4btoul(zoned_bdc->max_seq_req_zones); in dadone_probezone()
5888 softc->zone_flags |= DA_ZONE_FLAG_MAX_SEQ_SET; in dadone_probezone()
5895 * Re-check this assumption once the SAT spec is in dadone_probezone()
5902 softc->zone_flags |= DA_ZONE_FLAG_SUP_MASK; in dadone_probezone()
5909 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { in dadone_probezone()
5911 cam_release_devq(done_ccb->ccb_h.path, in dadone_probezone()
5920 free(csio->data_ptr, M_SCSIDA); in dadone_probezone()
5931 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_tur\n")); in dadone_tur()
5933 softc = (struct da_softc *)periph->softc; in dadone_tur()
5937 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { in dadone_tur()
5941 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) in dadone_tur()
5942 cam_release_devq(done_ccb->ccb_h.path, in dadone_tur()
5948 softc->flags &= ~DA_FLAG_TUR_PENDING; in dadone_tur()
5960 softc = (struct da_softc *)periph->softc; in dareprobe()
5965 if (softc->state != DA_STATE_NORMAL) in dareprobe()
5971 softc->state = DA_STATE_PROBE_WP; in dareprobe()
5983 if (ccb->csio.bio != NULL) in daerror()
5984 biotrack(ccb->csio.bio, __func__); in daerror()
5987 periph = xpt_path_periph(ccb->ccb_h.path); in daerror()
5988 softc = (struct da_softc *)periph->softc; in daerror()
5997 if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INVALID) { in daerror()
6010 xpt_print(periph->path, "Capacity data has changed\n"); in daerror()
6011 softc->flags &= ~DA_FLAG_PROBED; in daerror()
6017 softc->flags &= ~DA_FLAG_PROBED; in daerror()
6018 disk_media_changed(softc->disk, M_NOWAIT); in daerror()
6022 xpt_print(periph->path, "INQUIRY data has changed\n"); in daerror()
6023 softc->flags &= ~DA_FLAG_PROBED; in daerror()
6027 asc == 0x3a && (softc->flags & DA_FLAG_PACK_INVALID) == 0) { in daerror()
6029 /* 3a/1: MEDIUM NOT PRESENT - TRAY CLOSED */ in daerror()
6030 /* 3a/2: MEDIUM NOT PRESENT - TRAY OPEN */ in daerror()
6031 /* 3a/3: MEDIUM NOT PRESENT - LOADABLE */ in daerror()
6032 /* 3a/4: MEDIUM NOT PRESENT - MEDIUM AUXILIARY MEMORY ACCESSIBLE */ in daerror()
6033 softc->flags |= DA_FLAG_PACK_INVALID; in daerror()
6034 disk_media_gone(softc->disk, M_NOWAIT); in daerror()
6041 switch (ccb->ccb_h.status & CAM_STATUS_MASK) { in daerror()
6043 softc->timeouts++; in daerror()
6052 softc->errors++; in daerror()
6066 if (softc->quirks & DA_Q_RETRY_BUSY) in daerror()
6075 struct da_softc *softc = periph->softc; in damediapoll()
6077 if (!cam_iosched_has_work_flags(softc->cam_iosched, DA_WORK_TUR) && in damediapoll()
6078 (softc->flags & DA_FLAG_TUR_PENDING) == 0 && in damediapoll()
6079 softc->state == DA_STATE_NORMAL && in damediapoll()
6080 LIST_EMPTY(&softc->pending_ccbs)) { in damediapoll()
6082 cam_iosched_set_work_flags(softc->cam_iosched, DA_WORK_TUR); in damediapoll()
6089 callout_schedule_sbt(&softc->mediapoll_c, in damediapoll()
6102 softc = (struct da_softc *)periph->softc; in daprevent()
6105 && (softc->flags & DA_FLAG_PACK_LOCKED) == 0) in daprevent()
6107 && (softc->flags & DA_FLAG_PACK_LOCKED) != 0)) { in daprevent()
6113 scsi_prevent(&ccb->csio, in daprevent()
6122 SF_RETRY_UA | SF_NO_PRINT, softc->disk->d_devstat); in daprevent()
6126 softc->flags &= ~DA_FLAG_PACK_LOCKED; in daprevent()
6128 softc->flags |= DA_FLAG_PACK_LOCKED; in daprevent()
6144 softc = (struct da_softc *)periph->softc; in dasetgeom()
6146 dp = &softc->params; in dasetgeom()
6147 dp->secsize = block_len; in dasetgeom()
6148 dp->sectors = maxsector + 1; in dasetgeom()
6150 lbppbe = rcaplong->prot_lbppbe & SRC16_LBPPBE; in dasetgeom()
6151 lalba = scsi_2btoul(rcaplong->lalba_lbp); in dasetgeom()
6153 if (rcaplong->prot & SRC16_PROT_EN) in dasetgeom()
6154 softc->p_type = ((rcaplong->prot & SRC16_P_TYPE) >> in dasetgeom()
6157 softc->p_type = 0; in dasetgeom()
6161 softc->p_type = 0; in dasetgeom()
6165 dp->stripesize = block_len << lbppbe; in dasetgeom()
6166 dp->stripeoffset = (dp->stripesize - block_len * lalba) % in dasetgeom()
6167 dp->stripesize; in dasetgeom()
6168 } else if (softc->quirks & DA_Q_4K) { in dasetgeom()
6169 dp->stripesize = 4096; in dasetgeom()
6170 dp->stripeoffset = 0; in dasetgeom()
6171 } else if (softc->unmap_gran != 0) { in dasetgeom()
6172 dp->stripesize = block_len * softc->unmap_gran; in dasetgeom()
6173 dp->stripeoffset = (dp->stripesize - block_len * in dasetgeom()
6174 softc->unmap_gran_align) % dp->stripesize; in dasetgeom()
6176 dp->stripesize = 0; in dasetgeom()
6177 dp->stripeoffset = 0; in dasetgeom()
6188 xpt_setup_ccb(&ccg.ccb_h, periph->path, CAM_PRIORITY_NORMAL); in dasetgeom()
6190 ccg.block_size = dp->secsize; in dasetgeom()
6191 ccg.volume_size = dp->sectors; in dasetgeom()
6198 * We don't know what went wrong here- but just pick in dasetgeom()
6202 dp->heads = 255; in dasetgeom()
6203 dp->secs_per_track = 255; in dasetgeom()
6204 dp->cylinders = dp->sectors / (255 * 255); in dasetgeom()
6205 if (dp->cylinders == 0) { in dasetgeom()
6206 dp->cylinders = 1; in dasetgeom()
6209 dp->heads = ccg.heads; in dasetgeom()
6210 dp->secs_per_track = ccg.secs_per_track; in dasetgeom()
6211 dp->cylinders = ccg.cylinders; in dasetgeom()
6221 && (bcmp(rcaplong, &softc->rcaplong, in dasetgeom()
6222 min(sizeof(softc->rcaplong), rcap_len)) != 0)) { in dasetgeom()
6226 xpt_setup_ccb(&cdai.ccb_h, periph->path, CAM_PRIORITY_NORMAL); in dasetgeom()
6236 xpt_print(periph->path, "%s: failed to set read " in dasetgeom()
6242 bcopy(rcaplong, &softc->rcaplong, in dasetgeom()
6243 min(sizeof(softc->rcaplong), rcap_len)); in dasetgeom()
6247 softc->disk->d_sectorsize = softc->params.secsize; in dasetgeom()
6248 softc->disk->d_mediasize = softc->params.secsize * (off_t)softc->params.sectors; in dasetgeom()
6249 softc->disk->d_stripesize = softc->params.stripesize; in dasetgeom()
6250 softc->disk->d_stripeoffset = softc->params.stripeoffset; in dasetgeom()
6252 softc->disk->d_fwsectors = softc->params.secs_per_track; in dasetgeom()
6253 softc->disk->d_fwheads = softc->params.heads; in dasetgeom()
6254 softc->disk->d_devstat->block_size = softc->params.secsize; in dasetgeom()
6255 softc->disk->d_devstat->flags &= ~DEVSTAT_BS_UNAVAILABLE; in dasetgeom()
6257 error = disk_resize(softc->disk, M_NOWAIT); in dasetgeom()
6259 xpt_print(periph->path, "disk_resize(9) failed, error = %d\n", error); in dasetgeom()
6266 struct da_softc *softc = periph->softc; in dasendorderedtag()
6270 if (!LIST_EMPTY(&softc->pending_ccbs)) { in dasendorderedtag()
6271 if ((softc->flags & DA_FLAG_WAS_OTAG) == 0) in dasendorderedtag()
6272 softc->flags |= DA_FLAG_NEED_OTAG; in dasendorderedtag()
6273 softc->flags &= ~DA_FLAG_WAS_OTAG; in dasendorderedtag()
6278 callout_schedule_sbt(&softc->sendordered_c, in dasendorderedtag()
6285 * sync the disk cache to physical media.
6299 softc = (struct da_softc *)periph->softc; in dashutdown()
6303 (softc->flags & DA_FLAG_OPEN)) { in dashutdown()
6304 dadump(softc->disk, NULL, 0, 0); in dashutdown()
6311 * We only sync the cache if the drive is still open, and in dashutdown()
6314 if (((softc->flags & DA_FLAG_OPEN) == 0) in dashutdown()
6315 || (softc->quirks & DA_Q_NO_SYNC_CACHE)) { in dashutdown()
6321 scsi_synchronize_cache(&ccb->csio, in dashutdown()
6332 softc->disk->d_devstat); in dashutdown()
6334 xpt_print(periph->path, "Synchronize cache failed\n"); in dashutdown()
6356 scsi_cmd = (struct scsi_format_unit *)&csio->cdb_io.cdb_bytes; in scsi_format_unit()
6357 scsi_cmd->opcode = FORMAT_UNIT; in scsi_format_unit()
6358 scsi_cmd->byte2 = byte2; in scsi_format_unit()
6359 scsi_ulto2b(ileave, scsi_cmd->interleave); in scsi_format_unit()
6393 &csio->cdb_io.cdb_bytes; in scsi_read_defects()
6397 cdb10->opcode = READ_DEFECT_DATA_10; in scsi_read_defects()
6398 cdb10->format = list_format; in scsi_read_defects()
6399 scsi_ulto2b(dxfer_len, cdb10->alloc_length); in scsi_read_defects()
6404 &csio->cdb_io.cdb_bytes; in scsi_read_defects()
6408 cdb12->opcode = READ_DEFECT_DATA_12; in scsi_read_defects()
6409 cdb12->format = list_format; in scsi_read_defects()
6410 scsi_ulto4b(dxfer_len, cdb12->alloc_length); in scsi_read_defects()
6411 scsi_ulto4b(addr_desc_index, cdb12->address_descriptor_index); in scsi_read_defects()
6435 scsi_cmd = (struct scsi_sanitize *)&csio->cdb_io.cdb_bytes; in scsi_sanitize()
6436 scsi_cmd->opcode = SANITIZE; in scsi_sanitize()
6437 scsi_cmd->byte2 = byte2; in scsi_sanitize()
6438 scsi_cmd->control = control; in scsi_sanitize()
6439 scsi_ulto2b(dxfer_len, scsi_cmd->length); in scsi_sanitize()
6464 scsi_cmd = (struct scsi_zbc_out *)&csio->cdb_io.cdb_bytes; in scsi_zbc_out()
6465 scsi_cmd->opcode = ZBC_OUT; in scsi_zbc_out()
6466 scsi_cmd->service_action = service_action; in scsi_zbc_out()
6467 scsi_u64to8b(zone_id, scsi_cmd->zone_id); in scsi_zbc_out()
6468 scsi_cmd->zone_flags = zone_flags; in scsi_zbc_out()
6491 scsi_cmd = (struct scsi_zbc_in *)&csio->cdb_io.cdb_bytes; in scsi_zbc_in()
6492 scsi_cmd->opcode = ZBC_IN; in scsi_zbc_in()
6493 scsi_cmd->service_action = service_action; in scsi_zbc_in()
6494 scsi_ulto4b(dxfer_len, scsi_cmd->length); in scsi_zbc_in()
6495 scsi_u64to8b(zone_start_lba, scsi_cmd->zone_start_lba); in scsi_zbc_in()
6496 scsi_cmd->zone_options = zone_options; in scsi_zbc_in()
6550 * That isn't clear from the SAT-4 spec (as of rev 05). in scsi_ata_zac_mgmt_out()
6560 * field. That isn't clear in the SAT-4 spec (as in scsi_ata_zac_mgmt_out()