Lines Matching +full:sync +full:- +full:on +full:- +full:green +full:- +full:active

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
249 int outstanding_cmds; /* Number of active commands */
250 int refcount; /* Active xpt_action() calls */
327 /* Seagate Barracuda Green Advanced Format (4k) drives */
387 /* WDC Caviar Green Advanced Format (4k) drives */
392 /* WDC Caviar Green/Red Advanced Format (4k) drives */
412 /* WDC Caviar Green Advanced Format (4k) drives */
417 /* WDC Caviar Green Advanced Format (4k) drives */
447 { T_DIRECT, SIP_MEDIA_FIXED, "*", "Corsair CSSD-F*", "*" },
479 { T_DIRECT, SIP_MEDIA_FIXED, "*", "M4-CT???M4SSD2*", "*" },
501 * NCQ Trim doesn't work, but only on MU01 firmware
509 * NCQ Trim doesn't work, but only on MU01 firmware
519 { T_DIRECT, SIP_MEDIA_FIXED, "*", "C300-CTFDDAC???MAG*",
572 * Intel X25-M Series SSDs
647 { T_DIRECT, SIP_MEDIA_FIXED, "*", "OCZ-AGILITY2*", "*" },
655 { T_DIRECT, SIP_MEDIA_FIXED, "*", "OCZ-AGILITY3*", "*" },
679 { T_DIRECT, SIP_MEDIA_FIXED, "*", "OCZ-VERTEX3*", "*" },
687 { T_DIRECT, SIP_MEDIA_FIXED, "*", "OCZ-VERTEX4*", "*" },
803 * SAMSUNG HD200HJ KF100-06
813 * SAMSUNG HD501LJ CR100-10
828 /* WD Green SSD */
912 #define ADA_RA (softc->read_ahead >= 0 ? \
913 softc->read_ahead : ada_read_ahead)
914 #define ADA_WC (softc->write_cache >= 0 ? \
915 softc->write_cache : ada_write_cache)
940 &ada_read_ahead, 0, "Enable disk read-ahead");
983 periph = (struct cam_periph *)dp->d_drv1; in adaopen()
995 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH, in adaopen()
998 softc = (struct ada_softc *)periph->softc; in adaopen()
999 softc->flags |= ADA_FLAG_OPEN; in adaopen()
1014 periph = (struct cam_periph *)dp->d_drv1; in adaclose()
1015 softc = (struct ada_softc *)periph->softc; in adaclose()
1018 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH, in adaclose()
1021 /* We only sync the cache if the drive is capable of it. */ in adaclose()
1022 if ((softc->flags & ADA_FLAG_DIRTY) != 0 && in adaclose()
1023 (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) != 0 && in adaclose()
1024 (periph->flags & CAM_PERIPH_INVALID) == 0 && in adaclose()
1027 cam_fill_ataio(&ccb->ataio, in adaclose()
1036 if (softc->flags & ADA_FLAG_CAN_48BIT) in adaclose()
1037 ata_48bit_cmd(&ccb->ataio, ATA_FLUSHCACHE48, 0, 0, 0); in adaclose()
1039 ata_28bit_cmd(&ccb->ataio, ATA_FLUSHCACHE, 0, 0, 0); in adaclose()
1041 /*sense_flags*/0, softc->disk->d_devstat); in adaclose()
1044 xpt_print(periph->path, "Synchronize cache failed\n"); in adaclose()
1045 softc->flags &= ~ADA_FLAG_DIRTY; in adaclose()
1050 softc->flags &= ~ADA_FLAG_OPEN; in adaclose()
1052 while (softc->refcount != 0) in adaclose()
1053 cam_periph_sleep(periph, &softc->refcount, PRIBIO, "adaclose", 1); in adaclose()
1062 struct ada_softc *softc = (struct ada_softc *)periph->softc; in adaschedule()
1064 if (softc->state != ADA_STATE_NORMAL) in adaschedule()
1067 cam_iosched_schedule(softc->cam_iosched, periph); in adaschedule()
1081 periph = (struct cam_periph *)bp->bio_disk->d_drv1; in adastrategy()
1082 softc = (struct ada_softc *)periph->softc; in adastrategy()
1086 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("adastrategy(%p)\n", bp)); in adastrategy()
1091 if ((periph->flags & CAM_PERIPH_INVALID) != 0) { in adastrategy()
1098 * Zone commands must be ordered, because they can depend on the in adastrategy()
1102 if (bp->bio_cmd == BIO_ZONE) in adastrategy()
1103 bp->bio_flags |= BIO_ORDERED; in adastrategy()
1108 cam_iosched_queue_work(softc->cam_iosched, bp); in adastrategy()
1132 periph = dp->d_drv1; in adadump()
1133 softc = (struct ada_softc *)periph->softc; in adadump()
1134 secsize = softc->params.secsize; in adadump()
1137 if ((periph->flags & CAM_PERIPH_INVALID) != 0) in adadump()
1142 xpt_setup_ccb(&ataio.ccb_h, periph->path, CAM_PRIORITY_NORMAL); in adadump()
1152 if ((softc->flags & ADA_FLAG_CAN_48BIT) && in adadump()
1169 if (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) { in adadump()
1170 xpt_setup_ccb(&ataio.ccb_h, periph->path, CAM_PRIORITY_NORMAL); in adadump()
1187 if (softc->flags & ADA_FLAG_CAN_48BIT) in adadump()
1194 xpt_print(periph->path, "Synchronize cache failed\n"); in adadump()
1240 periph = (struct cam_periph *)dp->d_drv1; in adadiskgonecb()
1250 softc = (struct ada_softc *)periph->softc; in adaoninvalidate()
1253 * De-register any async callbacks. in adaoninvalidate()
1255 xpt_register_async(0, adaasync, periph, periph->path); in adaoninvalidate()
1257 softc->invalidations++; in adaoninvalidate()
1266 cam_iosched_flush(softc->cam_iosched, NULL, ENXIO); in adaoninvalidate()
1272 disk_gone(softc->disk); in adaoninvalidate()
1280 softc = (struct ada_softc *)periph->softc; in adacleanup()
1284 cam_iosched_fini(softc->cam_iosched); in adacleanup()
1289 if ((softc->flags & ADA_FLAG_SCTX_INIT) != 0) { in adacleanup()
1291 if (sysctl_ctx_free(&softc->sysctl_stats_ctx) != 0) in adacleanup()
1292 xpt_print(periph->path, in adacleanup()
1295 if (sysctl_ctx_free(&softc->sysctl_ctx) != 0) in adacleanup()
1296 xpt_print(periph->path, in adacleanup()
1300 disk_destroy(softc->disk); in adacleanup()
1301 callout_drain(&softc->sendordered_c); in adacleanup()
1310 if (softc->flags & ADA_FLAG_CAN_NCQ_TRIM) in adasetdeletemethod()
1311 softc->delete_method = ADA_DELETE_NCQ_DSM_TRIM; in adasetdeletemethod()
1312 else if (softc->flags & ADA_FLAG_CAN_TRIM) in adasetdeletemethod()
1313 softc->delete_method = ADA_DELETE_DSM_TRIM; in adasetdeletemethod()
1314 else if ((softc->flags & ADA_FLAG_CAN_CFA) && !(softc->flags & ADA_FLAG_CAN_48BIT)) in adasetdeletemethod()
1315 softc->delete_method = ADA_DELETE_CFA_ERASE; in adasetdeletemethod()
1317 softc->delete_method = ADA_DELETE_NONE; in adasetdeletemethod()
1339 if (cgd->protocol != PROTO_ATA) in adaasync()
1361 softc = (struct ada_softc *)periph->softc; in adaasync()
1363 xpt_setup_ccb(&cgd.ccb_h, periph->path, CAM_PRIORITY_NORMAL); in adaasync()
1368 * Update our information based on the new Identify data. in adaasync()
1372 disk_resize(softc->disk, M_NOWAIT); in adaasync()
1383 softc = periph->softc; in adaasync()
1384 disk_attr_changed(softc->disk, "GEOM::physpath", in adaasync()
1392 softc = (struct ada_softc *)periph->softc; in adaasync()
1393 if (softc->state != ADA_STATE_NORMAL) in adaasync()
1395 if (ADA_RA >= 0 && softc->flags & ADA_FLAG_CAN_RAHEAD) in adaasync()
1396 softc->state = ADA_STATE_RAHEAD; in adaasync()
1397 else if (ADA_WC >= 0 && softc->flags & ADA_FLAG_CAN_WCACHE) in adaasync()
1398 softc->state = ADA_STATE_WCACHE; in adaasync()
1399 else if ((softc->flags & ADA_FLAG_CAN_LOG) in adaasync()
1400 && (softc->zone_mode != ADA_ZONE_NONE)) in adaasync()
1401 softc->state = ADA_STATE_LOGDIR; in adaasync()
1405 softc->state = ADA_STATE_NORMAL; in adaasync()
1425 switch (softc->zone_mode) { in adazonemodesysctl()
1461 if (softc->zone_flags & ada_zone_desc_table[i].value) { in adazonesupsysctl()
1488 if ((periph->flags & CAM_PERIPH_INVALID) != 0) { in adasysctlinit()
1493 softc = (struct ada_softc *)periph->softc; in adasysctlinit()
1494 snprintf(tmpstr, sizeof(tmpstr), "CAM ADA unit %d",periph->unit_number); in adasysctlinit()
1495 snprintf(tmpstr2, sizeof(tmpstr2), "%d", periph->unit_number); in adasysctlinit()
1497 sysctl_ctx_init(&softc->sysctl_ctx); in adasysctlinit()
1498 softc->flags |= ADA_FLAG_SCTX_INIT; in adasysctlinit()
1499 softc->sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&softc->sysctl_ctx, in adasysctlinit()
1502 if (softc->sysctl_tree == NULL) { in adasysctlinit()
1508 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1513 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in adasysctlinit()
1514 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in adasysctlinit()
1515 "trim_count", CTLFLAG_RD, &softc->trim_count, in adasysctlinit()
1517 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in adasysctlinit()
1518 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in adasysctlinit()
1519 "trim_ranges", CTLFLAG_RD, &softc->trim_ranges, in adasysctlinit()
1521 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in adasysctlinit()
1522 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in adasysctlinit()
1523 "trim_lbas", CTLFLAG_RD, &softc->trim_lbas, in adasysctlinit()
1525 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1527 &softc->read_ahead, 0, "Enable disk read ahead."); in adasysctlinit()
1528 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1530 &softc->write_cache, 0, "Enable disk write cache."); in adasysctlinit()
1531 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1536 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1541 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in adasysctlinit()
1542 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in adasysctlinit()
1543 "optimal_seq_zones", CTLFLAG_RD, &softc->optimal_seq_zones, in adasysctlinit()
1545 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in adasysctlinit()
1546 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in adasysctlinit()
1548 &softc->optimal_nonseq_zones, in adasysctlinit()
1549 "Optimal Number of Non-Sequentially Written Sequential Write " in adasysctlinit()
1551 SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, in adasysctlinit()
1552 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, in adasysctlinit()
1553 "max_seq_zones", CTLFLAG_RD, &softc->max_seq_zones, in adasysctlinit()
1555 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1559 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1561 &softc->flags, (u_int)ADA_FLAG_UNMAPPEDIO, adabitsysctl, "I", in adasysctlinit()
1563 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1565 &softc->flags, (u_int)ADA_FLAG_ROTATING, adabitsysctl, "I", in adasysctlinit()
1574 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1576 &softc->force_read_error, 0, in adasysctlinit()
1578 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1580 &softc->force_write_error, 0, in adasysctlinit()
1582 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1584 &softc->periodic_read_error, 0, in adasysctlinit()
1586 SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in adasysctlinit()
1593 softc->sysctl_stats_tree = SYSCTL_ADD_NODE(&softc->sysctl_stats_ctx, in adasysctlinit()
1594 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "stats", in adasysctlinit()
1596 SYSCTL_ADD_INT(&softc->sysctl_stats_ctx, in adasysctlinit()
1597 SYSCTL_CHILDREN(softc->sysctl_stats_tree), in adasysctlinit()
1599 &softc->timeouts, 0, in adasysctlinit()
1601 SYSCTL_ADD_INT(&softc->sysctl_stats_ctx, in adasysctlinit()
1602 SYSCTL_CHILDREN(softc->sysctl_stats_tree), in adasysctlinit()
1604 &softc->errors, 0, in adasysctlinit()
1606 SYSCTL_ADD_INT(&softc->sysctl_stats_ctx, in adasysctlinit()
1607 SYSCTL_CHILDREN(softc->sysctl_stats_tree), in adasysctlinit()
1609 &softc->invalidations, 0, in adasysctlinit()
1613 cam_iosched_sysctl_init(softc->cam_iosched, &softc->sysctl_ctx, in adasysctlinit()
1614 softc->sysctl_tree); in adasysctlinit()
1628 periph = (struct cam_periph *)bp->bio_disk->d_drv1; in adagetattr()
1630 ret = xpt_getattr(bp->bio_data, bp->bio_length, bp->bio_attribute, in adagetattr()
1631 periph->path); in adagetattr()
1634 bp->bio_completed = bp->bio_length; in adagetattr()
1648 value = softc->delete_method; in adadeletemethodsysctl()
1655 if (error != 0 || req->newptr == NULL) in adadeletemethodsysctl()
1658 if ((softc->flags & ADA_FLAG_CAN_CFA) && in adadeletemethodsysctl()
1659 !(softc->flags & ADA_FLAG_CAN_48BIT)) in adadeletemethodsysctl()
1661 if (softc->flags & ADA_FLAG_CAN_TRIM) in adadeletemethodsysctl()
1663 if (softc->flags & ADA_FLAG_CAN_NCQ_TRIM) in adadeletemethodsysctl()
1669 softc->delete_method = i; in adadeletemethodsysctl()
1684 if (error || !req->newptr) in adabitsysctl()
1698 if (softc->flags != 0) in adaflagssysctl()
1699 sbuf_printf(&sbuf, "0x%b", (unsigned)softc->flags, ADA_FLAG_STRING); in adaflagssysctl()
1711 if ((cgd->ident_data.capabilities1 & ATA_SUPPORT_DMA) && in adasetflags()
1712 (cgd->inq_flags & SID_DMA)) in adasetflags()
1713 softc->flags |= ADA_FLAG_CAN_DMA; in adasetflags()
1715 softc->flags &= ~ADA_FLAG_CAN_DMA; in adasetflags()
1717 if (cgd->ident_data.support.command2 & ATA_SUPPORT_ADDRESS48) { in adasetflags()
1718 softc->flags |= ADA_FLAG_CAN_48BIT; in adasetflags()
1719 if (cgd->inq_flags & SID_DMA48) in adasetflags()
1720 softc->flags |= ADA_FLAG_CAN_DMA48; in adasetflags()
1722 softc->flags &= ~ADA_FLAG_CAN_DMA48; in adasetflags()
1724 softc->flags &= ~(ADA_FLAG_CAN_48BIT | ADA_FLAG_CAN_DMA48); in adasetflags()
1726 if (cgd->ident_data.support.command2 & ATA_SUPPORT_FLUSHCACHE) in adasetflags()
1727 softc->flags |= ADA_FLAG_CAN_FLUSHCACHE; in adasetflags()
1729 softc->flags &= ~ADA_FLAG_CAN_FLUSHCACHE; in adasetflags()
1731 if (cgd->ident_data.support.command1 & ATA_SUPPORT_POWERMGT) in adasetflags()
1732 softc->flags |= ADA_FLAG_CAN_POWERMGT; in adasetflags()
1734 softc->flags &= ~ADA_FLAG_CAN_POWERMGT; in adasetflags()
1736 if ((cgd->ident_data.satacapabilities & ATA_SUPPORT_NCQ) && in adasetflags()
1737 (cgd->inq_flags & SID_DMA) && (cgd->inq_flags & SID_CmdQue)) in adasetflags()
1738 softc->flags |= ADA_FLAG_CAN_NCQ; in adasetflags()
1740 softc->flags &= ~ADA_FLAG_CAN_NCQ; in adasetflags()
1742 if ((cgd->ident_data.support_dsm & ATA_SUPPORT_DSM_TRIM) && in adasetflags()
1743 (cgd->inq_flags & SID_DMA) && in adasetflags()
1744 (softc->quirks & ADA_Q_NO_TRIM) == 0) { in adasetflags()
1745 softc->flags |= ADA_FLAG_CAN_TRIM; in adasetflags()
1746 softc->trim_max_ranges = TRIM_MAX_RANGES; in adasetflags()
1747 if (cgd->ident_data.max_dsm_blocks != 0) { in adasetflags()
1748 softc->trim_max_ranges = in adasetflags()
1749 min(cgd->ident_data.max_dsm_blocks * in adasetflags()
1750 ATA_DSM_BLK_RANGES, softc->trim_max_ranges); in adasetflags()
1759 if ((softc->quirks & ADA_Q_NCQ_TRIM_BROKEN) == 0 && in adasetflags()
1760 (softc->flags & ADA_FLAG_PIM_ATA_EXT) != 0 && in adasetflags()
1761 (cgd->ident_data.satacapabilities2 & in adasetflags()
1763 (softc->flags & ADA_FLAG_CAN_TRIM) != 0) in adasetflags()
1764 softc->flags |= ADA_FLAG_CAN_NCQ_TRIM; in adasetflags()
1766 softc->flags &= ~ADA_FLAG_CAN_NCQ_TRIM; in adasetflags()
1768 softc->flags &= ~(ADA_FLAG_CAN_TRIM | ADA_FLAG_CAN_NCQ_TRIM); in adasetflags()
1770 if (cgd->ident_data.support.command2 & ATA_SUPPORT_CFA) in adasetflags()
1771 softc->flags |= ADA_FLAG_CAN_CFA; in adasetflags()
1773 softc->flags &= ~ADA_FLAG_CAN_CFA; in adasetflags()
1781 if ((cgd->ident_data.support.extension & ATA_SUPPORT_GENLOG) in adasetflags()
1782 && ((softc->quirks & ADA_Q_LOG_BROKEN) == 0)) in adasetflags()
1783 softc->flags |= ADA_FLAG_CAN_LOG; in adasetflags()
1785 softc->flags &= ~ADA_FLAG_CAN_LOG; in adasetflags()
1787 if ((cgd->ident_data.support3 & ATA_SUPPORT_ZONE_MASK) == in adasetflags()
1789 softc->zone_mode = ADA_ZONE_HOST_AWARE; in adasetflags()
1790 else if (((cgd->ident_data.support3 & ATA_SUPPORT_ZONE_MASK) == in adasetflags()
1792 || (softc->quirks & ADA_Q_SMR_DM)) in adasetflags()
1793 softc->zone_mode = ADA_ZONE_DRIVE_MANAGED; in adasetflags()
1795 softc->zone_mode = ADA_ZONE_NONE; in adasetflags()
1797 if (cgd->ident_data.support.command1 & ATA_SUPPORT_LOOKAHEAD) in adasetflags()
1798 softc->flags |= ADA_FLAG_CAN_RAHEAD; in adasetflags()
1800 softc->flags &= ~ADA_FLAG_CAN_RAHEAD; in adasetflags()
1802 if (cgd->ident_data.support.command1 & ATA_SUPPORT_WRITECACHE) in adasetflags()
1803 softc->flags |= ADA_FLAG_CAN_WCACHE; in adasetflags()
1805 softc->flags &= ~ADA_FLAG_CAN_WCACHE; in adasetflags()
1834 announce_buf = softc->announce_temp; in adaregister()
1837 periph->softc = softc; in adaregister()
1838 xpt_path_inq(&softc->cpi, periph->path); in adaregister()
1843 match = cam_quirkmatch((caddr_t)&cgd->ident_data, in adaregister()
1848 softc->quirks = ((struct ada_quirk_entry *)match)->quirks; in adaregister()
1850 softc->quirks = ADA_Q_NONE; in adaregister()
1852 TASK_INIT(&softc->sysctl_task, 0, adasysctlinit, periph); in adaregister()
1855 * Take a reference on the periph while adastart is called to finish in adaregister()
1862 "kern.cam.ada.%d.quirks", periph->unit_number); in adaregister()
1863 quirks = softc->quirks; in adaregister()
1865 softc->quirks = quirks; in adaregister()
1866 softc->read_ahead = -1; in adaregister()
1868 "kern.cam.ada.%d.read_ahead", periph->unit_number); in adaregister()
1869 TUNABLE_INT_FETCH(announce_buf, &softc->read_ahead); in adaregister()
1870 softc->write_cache = -1; in adaregister()
1872 "kern.cam.ada.%d.write_cache", periph->unit_number); in adaregister()
1873 TUNABLE_INT_FETCH(announce_buf, &softc->write_cache); in adaregister()
1876 * Let XPT know we can use UMA-allocated CCBs. in adaregister()
1881 periph->ccb_zone = ada_ccb_zone; in adaregister()
1885 * Set support flags based on the Identify data and quirks. in adaregister()
1888 if (softc->cpi.hba_misc & PIM_ATA_EXT) in adaregister()
1889 softc->flags |= ADA_FLAG_PIM_ATA_EXT; in adaregister()
1891 /* Disable queue sorting for non-rotational media by default. */ in adaregister()
1892 if (cgd->ident_data.media_rotation_rate == ATA_RATE_NON_ROTATING) { in adaregister()
1893 softc->flags &= ~ADA_FLAG_ROTATING; in adaregister()
1895 softc->flags |= ADA_FLAG_ROTATING; in adaregister()
1897 softc->disk = disk_alloc(); in adaregister()
1899 softc->disk->d_devstat = devstat_new_entry(periph->periph_name, in adaregister()
1900 periph->unit_number, softc->params.secsize, in adaregister()
1903 XPORT_DEVSTAT_TYPE(softc->cpi.transport), in adaregister()
1905 softc->disk->d_open = adaopen; in adaregister()
1906 softc->disk->d_close = adaclose; in adaregister()
1907 softc->disk->d_strategy = adastrategy; in adaregister()
1908 softc->disk->d_getattr = adagetattr; in adaregister()
1909 if (cam_sim_pollable(periph->sim)) in adaregister()
1910 softc->disk->d_dump = adadump; in adaregister()
1911 softc->disk->d_gone = adadiskgonecb; in adaregister()
1912 softc->disk->d_name = "ada"; in adaregister()
1913 softc->disk->d_drv1 = periph; in adaregister()
1914 softc->disk->d_unit = periph->unit_number; in adaregister()
1916 if (cam_iosched_init(&softc->cam_iosched, periph, softc->disk, in adaregister()
1923 cam_iosched_set_sort_queue(softc->cam_iosched, in adaregister()
1924 (softc->flags & ADA_FLAG_ROTATING) ? -1 : 0); in adaregister()
1928 dp = &softc->params; in adaregister()
1931 ((uintmax_t)dp->secsize * dp->sectors) / (1024 * 1024), in adaregister()
1932 (uintmax_t)dp->sectors, dp->secsize); in adaregister()
1934 sbuf_new(&sb, softc->announce_buffer, ADA_ANNOUNCE_SZ, SBUF_FIXEDLEN); in adaregister()
1936 xpt_announce_quirks_sbuf(periph, &sb, softc->quirks, ADA_Q_BIT_STRING); in adaregister()
1945 taskqueue_enqueue(taskqueue_thread, &softc->sysctl_task); in adaregister()
1953 * not attach the device on failure. in adaregister()
1957 adaasync, periph, periph->path); in adaregister()
1963 callout_init_mtx(&softc->sendordered_c, cam_periph_mtx(periph), 0); in adaregister()
1964 callout_reset_sbt(&softc->sendordered_c, in adaregister()
1971 if (ADA_RA >= 0 && softc->flags & ADA_FLAG_CAN_RAHEAD) { in adaregister()
1972 softc->state = ADA_STATE_RAHEAD; in adaregister()
1973 } else if (ADA_WC >= 0 && softc->flags & ADA_FLAG_CAN_WCACHE) { in adaregister()
1974 softc->state = ADA_STATE_WCACHE; in adaregister()
1975 } else if ((softc->flags & ADA_FLAG_CAN_LOG) in adaregister()
1976 && (softc->zone_mode != ADA_ZONE_NONE)) { in adaregister()
1977 softc->state = ADA_STATE_LOGDIR; in adaregister()
1994 uint64_t lastlba = (uint64_t)-1, lbas = 0; in ada_dsmtrim_req_create()
1998 TAILQ_INIT(&req->bps); in ada_dsmtrim_req_create()
2000 uint64_t lba = bp->bio_pblkno; in ada_dsmtrim_req_create()
2001 int count = bp->bio_bcount / softc->params.secsize; in ada_dsmtrim_req_create()
2005 c = min(count, ATA_DSM_RANGE_MAX - lastcount); in ada_dsmtrim_req_create()
2007 off = (ranges - 1) * ATA_DSM_RANGE_SIZE; in ada_dsmtrim_req_create()
2008 req->data[off + 6] = lastcount & 0xff; in ada_dsmtrim_req_create()
2009 req->data[off + 7] = in ada_dsmtrim_req_create()
2011 count -= c; in ada_dsmtrim_req_create()
2019 req->data[off + 0] = lba & 0xff; in ada_dsmtrim_req_create()
2020 req->data[off + 1] = (lba >> 8) & 0xff; in ada_dsmtrim_req_create()
2021 req->data[off + 2] = (lba >> 16) & 0xff; in ada_dsmtrim_req_create()
2022 req->data[off + 3] = (lba >> 24) & 0xff; in ada_dsmtrim_req_create()
2023 req->data[off + 4] = (lba >> 32) & 0xff; in ada_dsmtrim_req_create()
2024 req->data[off + 5] = (lba >> 40) & 0xff; in ada_dsmtrim_req_create()
2025 req->data[off + 6] = c & 0xff; in ada_dsmtrim_req_create()
2026 req->data[off + 7] = (c >> 8) & 0xff; in ada_dsmtrim_req_create()
2029 count -= c; in ada_dsmtrim_req_create()
2039 TAILQ_INSERT_TAIL(&req->bps, bp, bio_queue); in ada_dsmtrim_req_create()
2041 bp = cam_iosched_next_trim(softc->cam_iosched); in ada_dsmtrim_req_create()
2044 if (bp->bio_bcount / softc->params.secsize > in ada_dsmtrim_req_create()
2045 (softc->trim_max_ranges - ranges) * ATA_DSM_RANGE_MAX) { in ada_dsmtrim_req_create()
2046 cam_iosched_put_back_trim(softc->cam_iosched, bp); in ada_dsmtrim_req_create()
2050 softc->trim_count++; in ada_dsmtrim_req_create()
2051 softc->trim_ranges += ranges; in ada_dsmtrim_req_create()
2052 softc->trim_lbas += lbas; in ada_dsmtrim_req_create()
2060 struct trim_request *req = &softc->trim_req; in ada_dsmtrim()
2069 req->data, in ada_dsmtrim()
2079 struct trim_request *req = &softc->trim_req; in ada_ncq_dsmtrim()
2088 req->data, in ada_ncq_dsmtrim()
2095 ataio->cmd.sector_count_exp = ATA_SFPDMA_DSM; in ada_ncq_dsmtrim()
2096 ataio->ata_flags |= ATA_FLAG_AUX; in ada_ncq_dsmtrim()
2097 ataio->aux = 1; in ada_ncq_dsmtrim()
2103 struct trim_request *req = &softc->trim_req; in ada_cfaerase()
2104 uint64_t lba = bp->bio_pblkno; in ada_cfaerase()
2105 uint16_t count = bp->bio_bcount / softc->params.secsize; in ada_cfaerase()
2108 TAILQ_INIT(&req->bps); in ada_cfaerase()
2109 TAILQ_INSERT_TAIL(&req->bps, bp, bio_queue); in ada_cfaerase()
2139 return -1; in ada_zone_bio_to_ata()
2151 if (bp->bio_cmd != BIO_ZONE) { in ada_zone_cmd()
2156 softc = periph->softc; in ada_zone_cmd()
2158 switch (bp->bio_zone.zone_cmd) { in ada_zone_cmd()
2167 zone_sa = ada_zone_bio_to_ata(bp->bio_zone.zone_cmd); in ada_zone_cmd()
2168 if (zone_sa == -1) { in ada_zone_cmd()
2169 xpt_print(periph->path, "Cannot translate zone " in ada_zone_cmd()
2170 "cmd %#x to ATA\n", bp->bio_zone.zone_cmd); in ada_zone_cmd()
2176 lba = bp->bio_zone.zone_params.rwp.id; in ada_zone_cmd()
2178 if (bp->bio_zone.zone_params.rwp.flags & in ada_zone_cmd()
2182 ata_zac_mgmt_out(&ccb->ataio, in ada_zone_cmd()
2185 /*use_ncq*/ (softc->flags & in ada_zone_cmd()
2203 rep = &bp->bio_zone.zone_params.report; in ada_zone_cmd()
2205 num_entries = rep->entries_allocated; in ada_zone_cmd()
2207 xpt_print(periph->path, "No entries allocated for " in ada_zone_cmd()
2214 alloc_size = min(alloc_size, softc->disk->d_maxsize); in ada_zone_cmd()
2217 xpt_print(periph->path, "Unable to allocate memory " in ada_zone_cmd()
2223 ata_zac_mgmt_in(&ccb->ataio, in ada_zone_cmd()
2226 /*use_ncq*/ (softc->flags & in ada_zone_cmd()
2229 /*zone_id*/ rep->starting_id, in ada_zone_cmd()
2230 /*zone_flags*/ rep->rep_options, in ada_zone_cmd()
2242 * it. devstat uses bio_bcount - bio_resid to calculate in ada_zone_cmd()
2244 * uses bio_length - bio_resid to calculate the amount of in ada_zone_cmd()
2259 bp->bio_bcount = bp->bio_length; in ada_zone_cmd()
2268 params = &bp->bio_zone.zone_params.disk_params; in ada_zone_cmd()
2271 switch (softc->zone_mode) { in ada_zone_cmd()
2273 params->zone_mode = DISK_ZONE_MODE_DRIVE_MANAGED; in ada_zone_cmd()
2276 params->zone_mode = DISK_ZONE_MODE_HOST_AWARE; in ada_zone_cmd()
2279 params->zone_mode = DISK_ZONE_MODE_HOST_MANAGED; in ada_zone_cmd()
2283 params->zone_mode = DISK_ZONE_MODE_NONE; in ada_zone_cmd()
2287 if (softc->zone_flags & ADA_ZONE_FLAG_URSWRZ) in ada_zone_cmd()
2288 params->flags |= DISK_ZONE_DISK_URSWRZ; in ada_zone_cmd()
2290 if (softc->zone_flags & ADA_ZONE_FLAG_OPT_SEQ_SET) { in ada_zone_cmd()
2291 params->optimal_seq_zones = softc->optimal_seq_zones; in ada_zone_cmd()
2292 params->flags |= DISK_ZONE_OPT_SEQ_SET; in ada_zone_cmd()
2295 if (softc->zone_flags & ADA_ZONE_FLAG_OPT_NONSEQ_SET) { in ada_zone_cmd()
2296 params->optimal_nonseq_zones = in ada_zone_cmd()
2297 softc->optimal_nonseq_zones; in ada_zone_cmd()
2298 params->flags |= DISK_ZONE_OPT_NONSEQ_SET; in ada_zone_cmd()
2301 if (softc->zone_flags & ADA_ZONE_FLAG_MAX_SEQ_SET) { in ada_zone_cmd()
2302 params->max_seq_zones = softc->max_seq_zones; in ada_zone_cmd()
2303 params->flags |= DISK_ZONE_MAX_SEQ_SET; in ada_zone_cmd()
2305 if (softc->zone_flags & ADA_ZONE_FLAG_RZ_SUP) in ada_zone_cmd()
2306 params->flags |= DISK_ZONE_RZ_SUP; in ada_zone_cmd()
2308 if (softc->zone_flags & ADA_ZONE_FLAG_OPEN_SUP) in ada_zone_cmd()
2309 params->flags |= DISK_ZONE_OPEN_SUP; in ada_zone_cmd()
2311 if (softc->zone_flags & ADA_ZONE_FLAG_CLOSE_SUP) in ada_zone_cmd()
2312 params->flags |= DISK_ZONE_CLOSE_SUP; in ada_zone_cmd()
2314 if (softc->zone_flags & ADA_ZONE_FLAG_FINISH_SUP) in ada_zone_cmd()
2315 params->flags |= DISK_ZONE_FINISH_SUP; in ada_zone_cmd()
2317 if (softc->zone_flags & ADA_ZONE_FLAG_RWP_SUP) in ada_zone_cmd()
2318 params->flags |= DISK_ZONE_RWP_SUP; in ada_zone_cmd()
2331 struct ada_softc *softc = (struct ada_softc *)periph->softc; in adastart()
2332 struct ccb_ataio *ataio = &start_ccb->ataio; in adastart()
2334 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("adastart\n")); in adastart()
2336 switch (softc->state) { in adastart()
2342 bp = cam_iosched_next_bio(softc->cam_iosched); in adastart()
2348 if ((bp->bio_flags & BIO_ORDERED) != 0 || in adastart()
2349 (bp->bio_cmd != BIO_DELETE && (softc->flags & ADA_FLAG_NEED_OTAG) != 0)) { in adastart()
2350 softc->flags &= ~ADA_FLAG_NEED_OTAG; in adastart()
2351 softc->flags |= ADA_FLAG_WAS_OTAG; in adastart()
2356 switch (bp->bio_cmd) { in adastart()
2360 uint64_t lba = bp->bio_pblkno; in adastart()
2361 uint16_t count = bp->bio_bcount / softc->params.secsize; in adastart()
2365 if (bp->bio_cmd == BIO_WRITE) { in adastart()
2366 softc->flags |= ADA_FLAG_DIRTY; in adastart()
2372 data_ptr = bp->bio_data; in adastart()
2373 if ((bp->bio_flags & (BIO_UNMAPPED|BIO_VLIST)) != 0) { in adastart()
2390 if (bp->bio_cmd == BIO_READ) { in adastart()
2391 if (softc->force_read_error) { in adastart()
2392 softc->force_read_error--; in adastart()
2395 if (softc->periodic_read_error > 0) { in adastart()
2396 if (++softc->periodic_read_count >= in adastart()
2397 softc->periodic_read_error) { in adastart()
2398 softc->periodic_read_count = 0; in adastart()
2403 if (softc->force_write_error) { in adastart()
2404 softc->force_write_error--; in adastart()
2415 KASSERT((bp->bio_flags & BIO_UNMAPPED) == 0 || in adastart()
2416 round_page(bp->bio_bcount + bp->bio_ma_offset) / in adastart()
2417 PAGE_SIZE == bp->bio_ma_n, in adastart()
2425 bp->bio_bcount, in adastart()
2428 if ((softc->flags & ADA_FLAG_CAN_NCQ) && tag_code) { in adastart()
2429 if (bp->bio_cmd == BIO_READ) { in adastart()
2436 } else if ((softc->flags & ADA_FLAG_CAN_48BIT) && in adastart()
2439 if (softc->flags & ADA_FLAG_CAN_DMA48) { in adastart()
2440 if (bp->bio_cmd == BIO_READ) { in adastart()
2448 if (bp->bio_cmd == BIO_READ) { in adastart()
2459 if (softc->flags & ADA_FLAG_CAN_DMA) { in adastart()
2460 if (bp->bio_cmd == BIO_READ) { in adastart()
2468 if (bp->bio_cmd == BIO_READ) { in adastart()
2480 switch (softc->delete_method) { in adastart()
2496 start_ccb->ccb_h.ccb_state = ADA_CCB_TRIM; in adastart()
2497 start_ccb->ccb_h.flags |= CAM_UNLOCKED; in adastart()
2498 cam_iosched_submit_trim(softc->cam_iosched); in adastart()
2510 if (softc->flags & ADA_FLAG_CAN_48BIT) in adastart()
2543 start_ccb->ccb_h.ccb_state = ADA_CCB_BUFFER_IO; in adastart()
2544 start_ccb->ccb_h.flags |= CAM_UNLOCKED; in adastart()
2546 start_ccb->ccb_h.ccb_bp = bp; in adastart()
2547 softc->outstanding_cmds++; in adastart()
2548 softc->refcount++; in adastart()
2569 if (softc->state == ADA_STATE_RAHEAD) { in adastart()
2572 start_ccb->ccb_h.ccb_state = ADA_CCB_RAHEAD; in adastart()
2576 start_ccb->ccb_h.ccb_state = ADA_CCB_WCACHE; in adastart()
2578 start_ccb->ccb_h.flags |= CAM_DEV_QFREEZE; in adastart()
2586 if ((softc->flags & ADA_FLAG_CAN_LOG) == 0) { in adastart()
2593 xpt_print(periph->path, "Couldn't malloc log_dir " in adastart()
2595 softc->state = ADA_STATE_NORMAL; in adastart()
2606 /*protocol*/ softc->flags & ADA_FLAG_CAN_DMA ? in adastart()
2612 start_ccb->ccb_h.ccb_state = ADA_CCB_LOGDIR; in adastart()
2622 xpt_print(periph->path, "Couldn't malloc id_dir " in adastart()
2634 /*protocol*/ softc->flags & ADA_FLAG_CAN_DMA ? in adastart()
2640 start_ccb->ccb_h.ccb_state = ADA_CCB_IDDIR; in adastart()
2650 xpt_print(periph->path, "Couldn't malloc sup_cap " in adastart()
2662 /*protocol*/ softc->flags & ADA_FLAG_CAN_DMA ? in adastart()
2668 start_ccb->ccb_h.ccb_state = ADA_CCB_SUP_CAP; in adastart()
2678 xpt_print(periph->path, "Couldn't malloc ata_zone " in adastart()
2690 /*protocol*/ softc->flags & ADA_FLAG_CAN_DMA ? in adastart()
2696 start_ccb->ccb_h.ccb_state = ADA_CCB_ZONE; in adastart()
2708 softc = (struct ada_softc *)periph->softc; in adaprobedone()
2712 * our CCB before releasing the reference on the peripheral. The in adaprobedone()
2719 softc->state = ADA_STATE_NORMAL; in adaprobedone()
2720 softc->flags |= ADA_FLAG_PROBED; in adaprobedone()
2722 if ((softc->flags & ADA_FLAG_ANNOUNCED) == 0) { in adaprobedone()
2723 softc->flags |= ADA_FLAG_ANNOUNCED; in adaprobedone()
2730 disk_create(softc->disk, DISK_VERSION); in adaprobedone()
2742 bp = (struct bio *)ccb->ccb_h.ccb_bp; in adazonedone()
2744 switch (bp->bio_zone.zone_cmd) { in adazonedone()
2759 rep = &bp->bio_zone.zone_params.report; in adazonedone()
2760 avail_len = ccb->ataio.dxfer_len - ccb->ataio.resid; in adazonedone()
2771 hdr = (struct scsi_report_zones_hdr *)ccb->ataio.data_ptr; in adazonedone()
2778 bp->bio_error = EIO; in adazonedone()
2779 bp->bio_flags |= BIO_ERROR; in adazonedone()
2780 bp->bio_resid = bp->bio_bcount; in adazonedone()
2784 hdr_len = le32dec(hdr->length); in adazonedone()
2786 rep->entries_available = hdr_len / sizeof(*desc); in adazonedone()
2788 rep->entries_available = 0; in adazonedone()
2795 rep->header.same = hdr->byte4 & SRZ_SAME_MASK; in adazonedone()
2796 rep->header.maximum_lba = le64dec(hdr->maximum_lba); in adazonedone()
2802 rep->entries_filled = 0; in adazonedone()
2803 bp->bio_resid = bp->bio_bcount; in adazonedone()
2807 num_avail = min((avail_len - sizeof(*hdr)) / sizeof(*desc), in adazonedone()
2813 rep->entries_filled = 0; in adazonedone()
2814 bp->bio_resid = bp->bio_bcount; in adazonedone()
2818 num_to_fill = min(num_avail, rep->entries_allocated); in adazonedone()
2824 rep->entries_filled = 0; in adazonedone()
2825 bp->bio_resid = bp->bio_bcount; in adazonedone()
2829 for (i = 0, desc = &hdr->desc_list[0], entry=&rep->entries[0]; in adazonedone()
2840 entry->zone_type = desc->zone_type & SRZ_TYPE_MASK; in adazonedone()
2841 entry->zone_condition = in adazonedone()
2842 (desc->zone_flags & SRZ_ZONE_COND_MASK) >> in adazonedone()
2844 entry->zone_flags |= desc->zone_flags & in adazonedone()
2846 entry->zone_length = le64dec(desc->zone_length); in adazonedone()
2847 entry->zone_start_lba = le64dec(desc->zone_start_lba); in adazonedone()
2848 entry->write_pointer_lba = in adazonedone()
2849 le64dec(desc->write_pointer_lba); in adazonedone()
2851 rep->entries_filled = num_to_fill; in adazonedone()
2858 bp->bio_resid = bp->bio_bcount - (num_to_fill * sizeof(*entry)); in adazonedone()
2869 bp->bio_zone.zone_cmd); in adazonedone()
2873 if (bp->bio_zone.zone_cmd == DISK_ZONE_REPORT_ZONES) in adazonedone()
2874 free(ccb->ataio.data_ptr, M_ATADA); in adazonedone()
2886 softc = (struct ada_softc *)periph->softc; in adadone()
2887 ataio = &done_ccb->ataio; in adadone()
2888 path = done_ccb->ccb_h.path; in adadone()
2889 priority = done_ccb->ccb_h.pinfo.priority; in adadone()
2893 state = ataio->ccb_h.ccb_state & ADA_CCB_TYPE_MASK; in adadone()
2902 bp = (struct bio *)done_ccb->ccb_h.ccb_bp; in adadone()
2903 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { in adadone()
2910 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) in adadone()
2917 * If we get an error on an NCQ DSM TRIM, fall back in adadone()
2918 * to a non-NCQ DSM TRIM forever. Please note that if in adadone()
2925 (softc->flags & ADA_FLAG_CAN_NCQ_TRIM) != 0) { in adadone()
2926 softc->flags &= ~ADA_FLAG_CAN_NCQ_TRIM; in adadone()
2931 if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) in adadone()
2936 bp->bio_error = error; in adadone()
2938 bp->bio_resid = bp->bio_bcount; in adadone()
2939 bp->bio_flags |= BIO_ERROR; in adadone()
2941 if (bp->bio_cmd == BIO_ZONE) in adadone()
2944 bp->bio_resid = 0; in adadone()
2946 bp->bio_resid = ataio->resid; in adadone()
2948 if ((bp->bio_resid > 0) in adadone()
2949 && (bp->bio_cmd != BIO_ZONE)) in adadone()
2950 bp->bio_flags |= BIO_ERROR; in adadone()
2952 softc->outstanding_cmds--; in adadone()
2953 if (softc->outstanding_cmds == 0) in adadone()
2954 softc->flags |= ADA_FLAG_WAS_OTAG; in adadone()
2963 cam_iosched_bio_complete(softc->cam_iosched, bp, done_ccb); in adadone()
2965 KASSERT(softc->refcount >= 1, ("adadone softc %p refcount %d", softc, softc->refcount)); in adadone()
2966 softc->refcount--; in adadone()
2972 TAILQ_CONCAT(&queue, &softc->trim_req.bps, bio_queue); in adadone()
2983 cam_iosched_trim_done(softc->cam_iosched); in adadone()
2988 bp1->bio_error = error; in adadone()
2990 bp1->bio_flags |= BIO_ERROR; in adadone()
2991 bp1->bio_resid = bp1->bio_bcount; in adadone()
2993 bp1->bio_resid = 0; in adadone()
3005 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { in adadone()
3010 } else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { in adadone()
3020 softc->state = ADA_STATE_WCACHE; in adadone()
3028 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { in adadone()
3033 } else if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { in adadone()
3045 if ((softc->flags & ADA_FLAG_CAN_LOG) in adadone()
3046 && (softc->zone_mode != ADA_ZONE_NONE)) { in adadone()
3048 softc->state = ADA_STATE_LOGDIR; in adadone()
3059 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in adadone()
3061 softc->valid_logdir_len = 0; in adadone()
3062 bzero(&softc->ata_logdir, sizeof(softc->ata_logdir)); in adadone()
3063 softc->valid_logdir_len = in adadone()
3064 ataio->dxfer_len - ataio->resid; in adadone()
3065 if (softc->valid_logdir_len > 0) in adadone()
3066 bcopy(ataio->data_ptr, &softc->ata_logdir, in adadone()
3067 min(softc->valid_logdir_len, in adadone()
3068 sizeof(softc->ata_logdir))); in adadone()
3076 if ((softc->valid_logdir_len >= in adadone()
3078 && (le16dec(softc->ata_logdir.header) == in adadone()
3080 && (le16dec(&softc->ata_logdir.num_pages[ in adadone()
3082 sizeof(uint16_t)) - sizeof(uint16_t)]) > 0)){ in adadone()
3083 softc->flags |= ADA_FLAG_CAN_IDLOG; in adadone()
3085 softc->flags &= ~ADA_FLAG_CAN_IDLOG; in adadone()
3099 softc->flags &= ~(ADA_FLAG_CAN_LOG | in adadone()
3101 if ((done_ccb->ccb_h.status & in adadone()
3104 cam_release_devq(done_ccb->ccb_h.path, in adadone()
3113 free(ataio->data_ptr, M_ATADA); in adadone()
3116 && (softc->flags & ADA_FLAG_CAN_IDLOG)) { in adadone()
3117 softc->state = ADA_STATE_IDDIR; in adadone()
3128 if ((ataio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in adadone()
3132 softc->valid_iddir_len = 0; in adadone()
3133 bzero(&softc->ata_iddir, sizeof(softc->ata_iddir)); in adadone()
3134 softc->flags &= ~(ADA_FLAG_CAN_SUPCAP | in adadone()
3136 softc->valid_iddir_len = in adadone()
3137 ataio->dxfer_len - ataio->resid; in adadone()
3138 if (softc->valid_iddir_len > 0) in adadone()
3139 bcopy(ataio->data_ptr, &softc->ata_iddir, in adadone()
3140 min(softc->valid_iddir_len, in adadone()
3141 sizeof(softc->ata_iddir))); in adadone()
3145 max_entries = softc->valid_iddir_len - entries_offset; in adadone()
3146 if ((softc->valid_iddir_len > (entries_offset + 1)) in adadone()
3147 && (le64dec(softc->ata_iddir.header) == in adadone()
3149 && (softc->ata_iddir.entry_count > 0)) { in adadone()
3152 num_entries = softc->ata_iddir.entry_count; in adadone()
3154 softc->valid_iddir_len - entries_offset); in adadone()
3157 if (softc->ata_iddir.entries[i] == in adadone()
3159 softc->flags |= in adadone()
3161 else if (softc->ata_iddir.entries[i]== in adadone()
3163 softc->flags |= in adadone()
3166 if ((softc->flags & in adadone()
3168 && (softc->flags & in adadone()
3183 * a non-zero number of pages present for in adadone()
3186 softc->flags &= ~ADA_FLAG_CAN_IDLOG; in adadone()
3187 if ((done_ccb->ccb_h.status & in adadone()
3190 cam_release_devq(done_ccb->ccb_h.path, in adadone()
3199 free(ataio->data_ptr, M_ATADA); in adadone()
3202 && (softc->flags & ADA_FLAG_CAN_SUPCAP)) { in adadone()
3203 softc->state = ADA_STATE_SUP_CAP; in adadone()
3213 if ((ataio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in adadone()
3220 ataio->data_ptr; in adadone()
3221 valid_len = ataio->dxfer_len - ataio->resid; in adadone()
3224 sup_zac_cap) + 1 + sizeof(sup_cap->sup_zac_cap); in adadone()
3228 zoned = le64dec(sup_cap->zoned_cap); in adadone()
3237 softc->zone_mode = in adadone()
3241 softc->zone_mode = in adadone()
3245 zac_cap = le64dec(sup_cap->sup_zac_cap); in adadone()
3248 softc->zone_flags |= in adadone()
3251 softc->zone_flags |= in adadone()
3254 softc->zone_flags |= in adadone()
3257 softc->zone_flags |= in adadone()
3260 softc->zone_flags |= in adadone()
3265 * ACS-4, r08 on April 28th, 2015. in adadone()
3271 softc->zone_flags |= in adadone()
3286 softc->flags &= ~ADA_FLAG_CAN_SUPCAP; in adadone()
3290 softc->zone_flags &= ~ADA_ZONE_FLAG_SUP_MASK; in adadone()
3291 if ((done_ccb->ccb_h.status & in adadone()
3294 cam_release_devq(done_ccb->ccb_h.path, in adadone()
3303 free(ataio->data_ptr, M_ATADA); in adadone()
3306 && (softc->flags & ADA_FLAG_CAN_ZONE)) { in adadone()
3307 softc->state = ADA_STATE_ZONE; in adadone()
3317 if ((ataio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { in adadone()
3322 zi_log = (struct ata_zoned_info_log *)ataio->data_ptr; in adadone()
3324 valid_len = ataio->dxfer_len - ataio->resid; in adadone()
3326 version_info) + 1 + sizeof(zi_log->version_info); in adadone()
3330 tmpvar = le64dec(zi_log->zoned_cap); in adadone()
3333 softc->zone_flags |= in adadone()
3336 softc->zone_flags &= in adadone()
3339 tmpvar = le64dec(zi_log->optimal_seq_zones); in adadone()
3341 softc->zone_flags |= in adadone()
3343 softc->optimal_seq_zones = (tmpvar & in adadone()
3346 softc->zone_flags &= in adadone()
3348 softc->optimal_seq_zones = 0; in adadone()
3351 tmpvar =le64dec(zi_log->optimal_nonseq_zones); in adadone()
3353 softc->zone_flags |= in adadone()
3355 softc->optimal_nonseq_zones = in adadone()
3358 softc->zone_flags &= in adadone()
3360 softc->optimal_nonseq_zones = 0; in adadone()
3363 tmpvar = le64dec(zi_log->max_seq_req_zones); in adadone()
3365 softc->zone_flags |= in adadone()
3367 softc->max_seq_zones = in adadone()
3370 softc->zone_flags &= in adadone()
3372 softc->max_seq_zones = 0; in adadone()
3381 softc->flags &= ~ADA_FLAG_CAN_ZONE; in adadone()
3382 softc->flags &= ~ADA_ZONE_FLAG_SET_MASK; in adadone()
3384 if ((done_ccb->ccb_h.status & in adadone()
3387 cam_release_devq(done_ccb->ccb_h.path, in adadone()
3395 free(ataio->data_ptr, M_ATADA); in adadone()
3401 /* No-op. We're polling */ in adadone()
3416 periph = xpt_path_periph(ccb->ccb_h.path); in adaerror()
3417 softc = (struct ada_softc *)periph->softc; in adaerror()
3419 switch (ccb->ccb_h.status & CAM_STATUS_MASK) { in adaerror()
3421 softc->timeouts++; in adaerror()
3429 softc->errors++; in adaerror()
3442 struct disk_params *dp = &softc->params; in adasetgeom()
3448 dp->secsize = ata_logical_sector_size(&cgd->ident_data); in adasetgeom()
3449 if ((cgd->ident_data.atavalid & ATA_FLAG_54_58) && in adasetgeom()
3450 cgd->ident_data.current_heads != 0 && in adasetgeom()
3451 cgd->ident_data.current_sectors != 0) { in adasetgeom()
3452 dp->heads = cgd->ident_data.current_heads; in adasetgeom()
3453 dp->secs_per_track = cgd->ident_data.current_sectors; in adasetgeom()
3454 dp->cylinders = cgd->ident_data.cylinders; in adasetgeom()
3455 dp->sectors = (uint32_t)cgd->ident_data.current_size_1 | in adasetgeom()
3456 ((uint32_t)cgd->ident_data.current_size_2 << 16); in adasetgeom()
3458 dp->heads = cgd->ident_data.heads; in adasetgeom()
3459 dp->secs_per_track = cgd->ident_data.sectors; in adasetgeom()
3460 dp->cylinders = cgd->ident_data.cylinders; in adasetgeom()
3461 dp->sectors = cgd->ident_data.cylinders * in adasetgeom()
3462 (uint32_t)(dp->heads * dp->secs_per_track); in adasetgeom()
3464 lbasize = (uint32_t)cgd->ident_data.lba_size_1 | in adasetgeom()
3465 ((uint32_t)cgd->ident_data.lba_size_2 << 16); in adasetgeom()
3468 if (cgd->ident_data.cylinders == 16383 || dp->sectors < lbasize) in adasetgeom()
3469 dp->sectors = lbasize; in adasetgeom()
3472 lbasize48 = ((uint64_t)cgd->ident_data.lba_size48_1) | in adasetgeom()
3473 ((uint64_t)cgd->ident_data.lba_size48_2 << 16) | in adasetgeom()
3474 ((uint64_t)cgd->ident_data.lba_size48_3 << 32) | in adasetgeom()
3475 ((uint64_t)cgd->ident_data.lba_size48_4 << 48); in adasetgeom()
3476 if ((cgd->ident_data.support.command2 & ATA_SUPPORT_ADDRESS48) && in adasetgeom()
3478 dp->sectors = lbasize48; in adasetgeom()
3480 maxio = softc->cpi.maxio; /* Honor max I/O size of SIM */ in adasetgeom()
3485 if (softc->flags & ADA_FLAG_CAN_48BIT) in adasetgeom()
3486 maxio = min(maxio, 65536 * softc->params.secsize); in adasetgeom()
3488 maxio = min(maxio, 256 * softc->params.secsize); in adasetgeom()
3489 if (softc->quirks & ADA_Q_128KB) in adasetgeom()
3491 softc->disk->d_maxsize = maxio; in adasetgeom()
3493 if (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) in adasetgeom()
3495 if (softc->flags & ADA_FLAG_CAN_TRIM) { in adasetgeom()
3497 softc->disk->d_delmaxsize = softc->params.secsize * in adasetgeom()
3498 ATA_DSM_RANGE_MAX * softc->trim_max_ranges; in adasetgeom()
3499 } else if ((softc->flags & ADA_FLAG_CAN_CFA) && in adasetgeom()
3500 !(softc->flags & ADA_FLAG_CAN_48BIT)) { in adasetgeom()
3502 softc->disk->d_delmaxsize = 256 * softc->params.secsize; in adasetgeom()
3504 softc->disk->d_delmaxsize = maxio; in adasetgeom()
3505 if ((softc->cpi.hba_misc & PIM_UNMAPPED) != 0) { in adasetgeom()
3507 softc->flags |= ADA_FLAG_UNMAPPEDIO; in adasetgeom()
3509 softc->disk->d_flags = d_flags; in adasetgeom()
3520 tmpsize = MIN(sizeof(softc->disk->d_descr) - 1, in adasetgeom()
3521 sizeof(cgd->ident_data.model)); in adasetgeom()
3522 memcpy(softc->disk->d_descr, cgd->ident_data.model, tmpsize); in adasetgeom()
3523 softc->disk->d_descr[tmpsize] = '\0'; in adasetgeom()
3525 tmpsize = MIN(sizeof(softc->disk->d_ident) - 1, in adasetgeom()
3526 sizeof(cgd->ident_data.serial)); in adasetgeom()
3527 memcpy(softc->disk->d_ident, cgd->ident_data.serial, tmpsize); in adasetgeom()
3528 softc->disk->d_ident[tmpsize] = '\0'; in adasetgeom()
3530 softc->disk->d_sectorsize = softc->params.secsize; in adasetgeom()
3531 softc->disk->d_mediasize = (off_t)softc->params.sectors * in adasetgeom()
3532 softc->params.secsize; in adasetgeom()
3533 if (ata_physical_sector_size(&cgd->ident_data) != in adasetgeom()
3534 softc->params.secsize) { in adasetgeom()
3535 softc->disk->d_stripesize = in adasetgeom()
3536 ata_physical_sector_size(&cgd->ident_data); in adasetgeom()
3537 softc->disk->d_stripeoffset = (softc->disk->d_stripesize - in adasetgeom()
3538 ata_logical_sector_offset(&cgd->ident_data)) % in adasetgeom()
3539 softc->disk->d_stripesize; in adasetgeom()
3540 } else if (softc->quirks & ADA_Q_4K) { in adasetgeom()
3541 softc->disk->d_stripesize = 4096; in adasetgeom()
3542 softc->disk->d_stripeoffset = 0; in adasetgeom()
3544 softc->disk->d_fwsectors = softc->params.secs_per_track; in adasetgeom()
3545 softc->disk->d_fwheads = softc->params.heads; in adasetgeom()
3546 softc->disk->d_rotation_rate = cgd->ident_data.media_rotation_rate; in adasetgeom()
3547 snprintf(softc->disk->d_attachment, sizeof(softc->disk->d_attachment), in adasetgeom()
3548 "%s%d", softc->cpi.dev_name, softc->cpi.unit_number); in adasetgeom()
3557 if (softc->outstanding_cmds > 0) { in adasendorderedtag()
3558 if ((softc->flags & ADA_FLAG_WAS_OTAG) == 0) in adasendorderedtag()
3559 softc->flags |= ADA_FLAG_NEED_OTAG; in adasendorderedtag()
3560 softc->flags &= ~ADA_FLAG_WAS_OTAG; in adasendorderedtag()
3565 callout_schedule_sbt(&softc->sendordered_c, in adasendorderedtag()
3572 * sync the disk cache to physical media.
3583 softc = (struct ada_softc *)periph->softc; in adaflush()
3587 (softc->flags & ADA_FLAG_OPEN)) { in adaflush()
3588 adadump(softc->disk, NULL, 0, 0); in adaflush()
3594 * We only sync the cache if the drive is still open, and in adaflush()
3597 if (((softc->flags & ADA_FLAG_OPEN) == 0) || in adaflush()
3598 (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) == 0) { in adaflush()
3604 cam_fill_ataio(&ccb->ataio, in adaflush()
3612 if (softc->flags & ADA_FLAG_CAN_48BIT) in adaflush()
3613 ata_48bit_cmd(&ccb->ataio, ATA_FLUSHCACHE48, 0, 0, 0); in adaflush()
3615 ata_28bit_cmd(&ccb->ataio, ATA_FLUSHCACHE, 0, 0, 0); in adaflush()
3619 softc->disk->d_devstat); in adaflush()
3621 xpt_print(periph->path, "Synchronize cache failed\n"); in adaflush()
3637 /* If we panicked with lock held - not recurse here. */ in adaspindown()
3641 softc = (struct ada_softc *)periph->softc; in adaspindown()
3643 * We only spin-down the drive if it is capable of it.. in adaspindown()
3645 if ((softc->flags & ADA_FLAG_CAN_POWERMGT) == 0) { in adaspindown()
3656 xpt_setup_ccb(&local_ccb.ccb_h, periph->path, in adaspindown()
3669 softc->disk->d_devstat); in adaspindown()
3671 xpt_print(periph->path, in adaspindown()
3677 xpt_print(periph->path, in adaspindown()
3685 xpt_print(periph->path, in adaspindown()
3697 xpt_print(periph->path, "spin-down\n"); in adaspindown()
3700 xpt_setup_ccb(&local_ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL); in adaspindown()
3714 softc->disk->d_devstat); in adaspindown()
3716 xpt_print(periph->path, "Spin-down disk failed\n"); in adaspindown()
3740 * shutdown when in the Active PM state in SMART attributes. in adashutdown()
3776 softc = (struct ada_softc *)periph->softc; in adaresume()
3778 * We only spin-down the drive if it is capable of it.. in adaresume()
3780 if ((softc->flags & ADA_FLAG_CAN_POWERMGT) == 0) { in adaresume()
3786 xpt_print(periph->path, "resume\n"); in adaresume()
3789 * Drop freeze taken due to CAM_DEV_QFREEZE flag set on in adaresume()
3792 cam_release_devq(periph->path, in adaresume()