Linux ATA/IDE development
 help / color / mirror / Atom feed
From: Robert Hancock <hancockrwd@gmail.com>
To: Tomas Lund <tlund@nxs.se>
Cc: linux-ide@vger.kernel.org
Subject: Re: sata_sil24 failed command: READ FPDMA QUEUED (resolved)
Date: Thu, 05 Aug 2010 23:03:26 -0600	[thread overview]
Message-ID: <4C5B979E.8050606@gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.61.1008030732251.24693@envy.nxs.se>

On 08/02/2010 11:33 PM, Tomas Lund wrote:
> On Mon, 2 Aug 2010, Robert Hancock wrote:
> 
>> On Mon, Aug 2, 2010 at 1:21 AM, Tomas Lund <tlund@nxs.se> wrote:
>>
>>> I have unlocked and tested a total of 4 disks now, both the samsung 1TB and 3 of the WDC 2TB disks. Thank you very much! Left to do: test that everything is working with the PMP aswell.
>>
>> Good to hear.
> 
> I now have all of my drives up and working, running on the PMP and everything is looking perfectly. Thanks again for your help.
> 
>>> Question: Would it be unreasonable to request that the kernel would issue the apropriate ATA-commands to a disk as soon as it is detected, and not try to read from it if it is locked? It would have been really, really nice to just get the error message "drive is locked".
>>
>> It should be possible to indicate that, yes. I'll look into it when I get a chance, if someone doesn't beat me to it..
> 
> Perfect!
> 
> //tlund

Can you test this patch out, assuming you still have anything left that's locked
(or can relock one of them to try it out)? It should print out a warning in
dmesg upon recognizing the device if it's in the security locked state.

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index ddf8e48..d4ec163 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2561,6 +2561,11 @@ int ata_dev_configure(struct ata_device *dev)
                                       dma_dir_string);
        }
 
+       if (print_info && ata_id_security_locked(dev->id))
+               ata_dev_printk(dev, KERN_WARNING,
+                       "appears to have ATA security enabled and locked - "
+                       "media may be inaccessible until unlocked\n");
+
        /* determine max_sectors */
        dev->max_sectors = ATA_MAX_SECTORS;
        if (dev->flags & ATA_DFLAG_LBA48)
diff --git a/include/linux/ata.h b/include/linux/ata.h
index fe6e681..f2359fa 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -684,6 +684,22 @@ static inline int ata_id_hpa_enabled(const u16 *id)
        return id[ATA_ID_COMMAND_SET_1] & (1 << 10);
 }
 
+static inline int ata_id_security_locked(const u16 *id)
+{
+       /* Yes children, word 83 valid bits cover word 82 data */
+       if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000)
+               return 0;
+       /* And 87 covers 85-87 */
+       if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
+               return 0;
+       /* Check command sets enabled as well as supported */
+       if ((id[ATA_ID_CFS_ENABLE_1] & (1 << 1)) == 0)
+               return 0;
+       if ((id[ATA_ID_COMMAND_SET_1] & (1 << 1)) == 0)
+               return 0;
+       return (id[ATA_ID_DLF] & 0x0007) == 0x0007;
+}
+
 static inline int ata_id_has_wcache(const u16 *id)
 {
        /* Yes children, word 83 valid bits cover word 82 data */


  reply	other threads:[~2010-08-06  5:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-13 21:09 sata_sil24 failed command: READ FPDMA QUEUED Tomas Lund
2010-07-14  1:30 ` Robert Hancock
2010-07-14  8:02   ` Tomas Lund
2010-07-15 19:05     ` Tomas Lund
2010-07-17 12:29       ` Tomas Lund
2010-07-21 12:06         ` Tomas Lund
2010-07-21 12:38           ` Tomas Lund
2010-07-30 18:30             ` Robert Hancock
2010-08-01 14:27               ` Tomas Lund
2010-08-01 16:55                 ` Tomas Lund
2010-08-01 21:15                 ` Robert Hancock
2010-08-02  7:21                   ` sata_sil24 failed command: READ FPDMA QUEUED (resolved) Tomas Lund
2010-08-02 18:23                     ` Robert Hancock
2010-08-03  5:33                       ` Tomas Lund
2010-08-06  5:03                         ` Robert Hancock [this message]
2010-08-12 14:09                           ` Gwendal Grignou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C5B979E.8050606@gmail.com \
    --to=hancockrwd@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=tlund@nxs.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox