Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'ata-6.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux

Pull ata fixes from Niklas Cassel:

- Add a missing refcount decrement in ata_scsi_dev_rescan() when
the device or its queue is not running.

In the case where the device is running, the recount is already
decremented properly (Yihang Li)

- Generate the proper sense code for a Security locked device.

There was a regression caused by a recent change of how sense
data is generated for commands that did not provide any sense
data. This broke system suspend for Security locked devices.

Generate the sense data that the SCSI disk driver expects for a
Security locked device so that system suspend works again (me)

- Set capacity to zero for a Security locked device.

All I/O commands will be aborted by a Security locked device.
Thus, the block layer disk partition scanning will result in
a bunch of, for the user, confusing I/O errors in dmesg during
boot.

Since a Security locked device is unusable anyway, set the capacity
to zero, to avoid the disk partition scanning during boot. We still
create the block device in /dev such that the user may unlock the
device using e.g. hdparm (me)

* tag 'ata-6.18-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux:
ata: libata-core: Set capacity to zero for a security locked drive
ata: libata-scsi: Fix system suspend for a security locked drive
ata: libata-scsi: Add missing scsi_device_put() in ata_scsi_dev_rescan()

+21 -1
+10
drivers/ata/libata-core.c
··· 3006 3006 } 3007 3007 3008 3008 dev->n_sectors = ata_id_n_sectors(id); 3009 + if (ata_id_is_locked(id)) { 3010 + /* 3011 + * If Security locked, set capacity to zero to prevent 3012 + * any I/O, e.g. partition scanning, as any I/O to a 3013 + * locked drive will result in user visible errors. 3014 + */ 3015 + ata_dev_info(dev, 3016 + "Security locked, setting capacity to zero\n"); 3017 + dev->n_sectors = 0; 3018 + } 3009 3019 3010 3020 /* get current R/W Multiple count setting */ 3011 3021 if ((dev->id[47] >> 8) == 0x80 && (dev->id[59] & 0x100)) {
+10 -1
drivers/ata/libata-scsi.c
··· 992 992 return; 993 993 } 994 994 995 + if (ata_id_is_locked(dev->id)) { 996 + /* Security locked */ 997 + /* LOGICAL UNIT ACCESS NOT AUTHORIZED */ 998 + ata_scsi_set_sense(dev, cmd, DATA_PROTECT, 0x74, 0x71); 999 + return; 1000 + } 1001 + 995 1002 if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { 996 1003 ata_dev_dbg(dev, 997 1004 "Missing result TF: reporting aborted command\n"); ··· 4901 4894 spin_unlock_irqrestore(ap->lock, flags); 4902 4895 if (do_resume) { 4903 4896 ret = scsi_resume_device(sdev); 4904 - if (ret == -EWOULDBLOCK) 4897 + if (ret == -EWOULDBLOCK) { 4898 + scsi_device_put(sdev); 4905 4899 goto unlock_scan; 4900 + } 4906 4901 dev->flags &= ~ATA_DFLAG_RESUMING; 4907 4902 } 4908 4903 ret = scsi_rescan_device(sdev);
+1
include/linux/ata.h
··· 566 566 #define ata_id_has_ncq(id) ((id)[ATA_ID_SATA_CAPABILITY] & (1 << 8)) 567 567 #define ata_id_queue_depth(id) (((id)[ATA_ID_QUEUE_DEPTH] & 0x1f) + 1) 568 568 #define ata_id_removable(id) ((id)[ATA_ID_CONFIG] & (1 << 7)) 569 + #define ata_id_is_locked(id) (((id)[ATA_ID_DLF] & 0x7) == 0x7) 569 570 #define ata_id_has_atapi_AN(id) \ 570 571 ((((id)[ATA_ID_SATA_CAPABILITY] != 0x0000) && \ 571 572 ((id)[ATA_ID_SATA_CAPABILITY] != 0xffff)) && \