linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
  • * Re: [PATCH 3/5] libata: Implement disk shock protection support
           [not found]   ` <fa.zGvATZImeUo0tHJe4hzlk5+mTiM@ifi.uio.no>
           [not found]     ` <fa.SRVleMItV5QEF7/tgCjSHz0ScJA@ifi.uio.no>
    @ 2008-08-05  4:16     ` Robert Hancock
      2008-08-05  7:49       ` Tejun Heo
      1 sibling, 1 reply; 23+ messages in thread
    From: Robert Hancock @ 2008-08-05  4:16 UTC (permalink / raw)
      To: Tejun Heo
      Cc: Elias Oltmanns, Alan Cox, Jeff Garzik, Bartlomiej Zolnierkiewicz,
    	James Bottomley, Pavel Machek, linux-ide, linux-kernel
    
    Tejun Heo wrote:
    > Elias Oltmanns wrote:
    >> On user request (through sysfs), the IDLE IMMEDIATE command with UNLOAD
    >> FEATURE as specified in ATA-7 is issued to the device and processing of
    >> the request queue is stopped thereafter until the speified timeout
    >> expires or user space asks to resume normal operation. This is supposed
    >> to prevent the heads of a hard drive from accidentally crashing onto the
    >> platter when a heavy shock is anticipated (like a falling laptop
    >> expected to hit the floor). This patch simply stops processing the
    >> request queue. In particular, it does not yet, for instance, defer an
    >> SRST issued in order to recover from an error on the other device on the
    >> interface.
    > 
    > For libata, the easiest way to achieve the above would be adding a
    > per-dev EH action, say, ATA_EH_UNLOAD and schedule EH w/ the action OR'd
    > to eh_info->action.  The EH_UNLOAD handler can then issue the command
    > wait for the specified number of seconds and continue.  This will be
    > pretty simple to implement as command exclusion and stuff are all
    > automatically handled by EH framework.
    > 
    > However, SATA or not, there simply isn't a way to abort commands in ATA.
    >  Issuing random command while other commands are in progress simply is
    > state machine violation and there will be many interesting results
    > including complete system lockup (ATA controller dying while holding the
    > PCI bus).  The only reliable way to abort in-flight commands are by
    > issuing hardreset.  However, ATA reset protocol is not designed for
    > quick recovery.  The machine is gonna hit the ground hard way before the
    > reset protocol is complete.
    
    How long does hardreset have to take? I only see a 1ms delay in the 
    COMRESET process (sata_link_hardreset). I'd think it would be feasible 
    to do something like:
    
    -stop the queue to prevent new commands from being issued
    -wait a certain amount of time (20ms or so?) for existing command(s) to 
    complete, if they do then issue the idle command
    -if time runs out, trigger a hardreset and then issue the idle command
    
    The drive is going to take a little while to actually unload the heads 
    anyway, so a few milliseconds delay doesn't seem like a big deal..
    
    > 
    > The only way to solve this nicely is either to build the accelerometer
    > into the drive and let the drive itself protect itself or implement a
    > sideband signal to tell it to duck for cover.  For SATA, this sideband
    > signal can be another OOB sequence.  If it's ever implemented this way,
    > it will be in SControl, I guess.
    > 
    > Well, short of that, all we can do is to wait for the currently
    > in-flight commands to drain and hope that it happens before the machine
    > hits the ground.  Also, that the harddrive is not going through one of
    > the longish EH recovery sequences when it starts to fall.  :-(
    
    Well, Lenovo (and others?) have implemented this in Windows somehow.. It 
    would be interesting to know what solution they used there (either 
    hardreset, issue the command even when busy, or just wait for the 
    commands to hopefully finish in time).
    
    
    ^ permalink raw reply	[flat|nested] 23+ messages in thread
  • * [RFC] Disk shock protection in GNU/Linux
    @ 2008-07-26  6:20 Elias Oltmanns
      2008-07-26  6:25 ` [PATCH 3/5] libata: Implement disk shock protection support Elias Oltmanns
      0 siblings, 1 reply; 23+ messages in thread
    From: Elias Oltmanns @ 2008-07-26  6:20 UTC (permalink / raw)
      To: Alan Cox, Jeff Garzik, Bartlomiej Zolnierkiewicz, James Bottomley
      Cc: Pavel Machek, linux-ide, linux-kernel
    
    Hi all,
    
    yet again, I'm trying to get this feature into the Linux kernel. This
    time, I have tried to arrange the code in such a way that hardly
    anything not strictly belonging to the libata or ide subsystem is
    touched at all. Since former attempts to design this in a more generic
    way involving the block and scsi layer have proven very difficult and
    since this is all about an ATA specific feature anyway, I think the best
    solution (for now at least) is to stick to those two subsystems as far
    as possible.
    
    Nevertheless, I'd welcome James' opinion on the third patch in the
    series with regard to the use of vendor specific cdbs. If it is
    acceptable in principle, the question remains whether we sould reserve
    part of the range 0xf800 - 0xffff of vendor specific service actions for
    the exclusive use by LLDDs (in much the way I did it here), or whether
    all these codes should be unique in the kernel and defined in scsi.h.
    
    Also, we have to agree upon a suitable way to deal with devices that
    actually do support the UNLOAD FEATURE but don't report that capability
    in their ID as specified in ATA-7. Perhaps we even want to fall back to
    STANDBY IMMEDIATE on devices that definitely don't support IDLE
    IMMEDIATE with UNLOAD FEATURE; this has been the case for the original
    hdaps / disk-protect patch but I'm not quite sure whether anybody
    actually relies on this feature and whether it would be advisable in the
    first place. Regarding devices that support head unloading but don't
    report it properly, there seem to be the following options:
    
    a) Provide an attribute in sysfs for the user to indicate that the
       device really does support the UNLOAD FEATURE.
    b) Issue the command (for the first time) anyway and check whether the
       device responds as specified in ATA-7. Make a note of the result and
       act accordingly from there on.
    
    The second option looks appealing because no user intervention is
    required and it is known to work at least for some devices. On the other
    hand, it may be dangerous on old hardware and I don't even know whether
    all pre-ATA-7 devices supporting the UNLOAD FEATURE really do return the
    correct data in the command registers.
    
    Here is a short description of the patches in this series applying
    cleanly on top of next-20080725:
    
    1. This is a trivial patch making things slightly easier for #3. More
       importantly though, it also fixes a potential memory leak and should
       probably be applied regardless of the rest of the series (Jeff?).
    2. This is a small patch to ata.h in order to provide a simple check for
       support of the UNLOAD FEATURE as indicated in a device's ID.
    3. Here disk head unloading is implemented in the libata subsystem. See
       the changelog entry for current shortcomings of this patch.
    4. The same for ide.
    5. A little bit of documentation.
    
    There are some questions I need your advice on that have been inserted
    as FIXME comments into the code. However, here is a more general
    question that interests me even though it could turn out to be a good
    idea (or at least acceptable) to merge these patches before that
    question has been fully resolved. Alan once mentioned that it might be
    desirable to abort commands currently in progress and issue IDLE
    IMMEDIATE straight away. My question is whether this is at all possible
    for non SATA command protocols. In volume 2 of the ATA-7 specification I
    haven't found a well defined way to abort or shor circuit, say, a DMA or
    PIO command in progress. It even says that after the host has aborted
    data transfer when DMA was in progress, it is supposed to initiate a
    SRST. Obviously, I'd like to avoid that at all costs.
    
    Thank you in advance for your cooperation,
    
    Elias
    
    ^ permalink raw reply	[flat|nested] 23+ messages in thread

    end of thread, other threads:[~2008-08-05 23:02 UTC | newest]
    
    Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
    -- links below jump to the message on this page --
         [not found] <fa.nx0yFPJm+aNXPHgykUrOzZXvvIs@ifi.uio.no>
         [not found] ` <fa.NfEr7Ik6e8oextyWICW/jR5emeE@ifi.uio.no>
         [not found]   ` <fa.zGvATZImeUo0tHJe4hzlk5+mTiM@ifi.uio.no>
         [not found]     ` <fa.SRVleMItV5QEF7/tgCjSHz0ScJA@ifi.uio.no>
         [not found]       ` <fa.YKbhgq8XUxH/Qg1ArE+73YsDlpE@ifi.uio.no>
    2008-08-05  4:05         ` [PATCH 3/5] libata: Implement disk shock protection support Robert Hancock
    2008-08-05 13:14           ` Theodore Tso
    2008-08-05 14:29             ` Henrique de Moraes Holschuh
    2008-08-05 15:14             ` Eric Piel
    2008-08-05 19:59             ` Pavel Machek
    2008-08-05 22:57               ` Elias Oltmanns
         [not found]             ` <48986E3A.5020707@tremplin-utc.net>
    2008-08-05 20:00               ` Pavel Machek
    2008-08-05  4:16     ` Robert Hancock
    2008-08-05  7:49       ` Tejun Heo
    2008-07-26  6:20 [RFC] Disk shock protection in GNU/Linux Elias Oltmanns
    2008-07-26  6:25 ` [PATCH 3/5] libata: Implement disk shock protection support Elias Oltmanns
    2008-08-01  7:19   ` Tejun Heo
    2008-08-01 22:34     ` Alan Cox
    2008-08-03  3:19       ` Tejun Heo
    2008-08-03 13:05         ` Alan Cox
    2008-08-03 13:58           ` Tejun Heo
    2008-08-04 13:43       ` Elias Oltmanns
    2008-08-04 13:26     ` Elias Oltmanns
    2008-08-04 14:12       ` Tejun Heo
    2008-08-04 16:54         ` Elias Oltmanns
    2008-08-04 23:26           ` Tejun Heo
    2008-08-04 14:28     ` Gabor Gombas
    2008-08-04 14:13       ` Alan Cox
    2008-08-04 14:35       ` Tejun Heo
    

    This is a public inbox, see mirroring instructions
    for how to clone and mirror all data and code used for this inbox;
    as well as URLs for NNTP newsgroup(s).