Skip to content

Commit 26d5805

Browse files
sbradshawmicronaxboe
authored andcommitted
mtip32xx: Correctly handle security locked condition
If power is removed during a secure erase, the drive will end up in a security locked condition. This patch causes the driver to identify, log, and flag the security lock state. IOs are prevented from submission to the drive until the locked state is addressed with a secure erase. Bumped version number to reflect this capability. Signed-off-by: Sam Bradshaw <sbradshaw@micron.com> Signed-off-by: Asai Thambi S P <asamymuthupa@micron.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 188b9f4 commit 26d5805

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

drivers/block/mtip32xx/mtip32xx.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,8 +920,9 @@ static void mtip_handle_tfe(struct driver_data *dd)
920920
fail_reason = "thermal shutdown";
921921
}
922922
if (buf[288] == 0xBF) {
923+
set_bit(MTIP_DDF_SEC_LOCK_BIT, &dd->dd_flag);
923924
dev_info(&dd->pdev->dev,
924-
"Drive indicates rebuild has failed.\n");
925+
"Drive indicates rebuild has failed. Secure erase required.\n");
925926
fail_all_ncq_cmds = 1;
926927
fail_reason = "rebuild failed";
927928
}
@@ -1587,6 +1588,12 @@ static int mtip_get_identify(struct mtip_port *port, void __user *user_buffer)
15871588
}
15881589
#endif
15891590

1591+
/* Check security locked state */
1592+
if (port->identify[128] & 0x4)
1593+
set_bit(MTIP_DDF_SEC_LOCK_BIT, &port->dd->dd_flag);
1594+
else
1595+
clear_bit(MTIP_DDF_SEC_LOCK_BIT, &port->dd->dd_flag);
1596+
15901597
#ifdef MTIP_TRIM /* Disabling TRIM support temporarily */
15911598
/* Demux ID.DRAT & ID.RZAT to determine trim support */
15921599
if (port->identify[69] & (1 << 14) && port->identify[69] & (1 << 5))
@@ -1908,6 +1915,10 @@ static void mtip_dump_identify(struct mtip_port *port)
19081915
strlcpy(cbuf, (char *)(port->identify+27), 41);
19091916
dev_info(&port->dd->pdev->dev, "Model: %s\n", cbuf);
19101917

1918+
dev_info(&port->dd->pdev->dev, "Security: %04x %s\n",
1919+
port->identify[128],
1920+
port->identify[128] & 0x4 ? "(LOCKED)" : "");
1921+
19111922
if (mtip_hw_get_capacity(port->dd, &sectors))
19121923
dev_info(&port->dd->pdev->dev,
19131924
"Capacity: %llu sectors (%llu MB)\n",
@@ -3678,7 +3689,8 @@ static int mtip_hw_exit(struct driver_data *dd)
36783689
* saves its state.
36793690
*/
36803691
if (!dd->sr) {
3681-
if (!test_bit(MTIP_DDF_REBUILD_FAILED_BIT, &dd->dd_flag))
3692+
if (!test_bit(MTIP_PF_REBUILD_BIT, &dd->port->flags) &&
3693+
!test_bit(MTIP_DDF_SEC_LOCK_BIT, &dd->dd_flag))
36823694
if (mtip_standby_immediate(dd->port))
36833695
dev_warn(&dd->pdev->dev,
36843696
"STANDBY IMMEDIATE failed\n");

drivers/block/mtip32xx/mtip32xx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292

9393
/* Driver name and version strings */
9494
#define MTIP_DRV_NAME "mtip32xx"
95-
#define MTIP_DRV_VERSION "1.2.6os3"
95+
#define MTIP_DRV_VERSION "1.3.0"
9696

9797
/* Maximum number of minor device numbers per device. */
9898
#define MTIP_MAX_MINORS 16

0 commit comments

Comments
 (0)