linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Recommendations on user-space soft/hardreset
       [not found] <6b01c6170707171723p4fdae403hf5b605fce4595b7@mail.gmail.com>
@ 2007-07-18  0:34 ` Yasha Okshtein
  2007-07-18  0:45   ` Alan Cox
  2007-07-18  3:35   ` Tejun Heo
  0 siblings, 2 replies; 14+ messages in thread
From: Yasha Okshtein @ 2007-07-18  0:34 UTC (permalink / raw)
  To: linux-ide

Hello all,

I need to send soft and/or hard resets from userspace. As no such
method exists, I decided to write one. I wrote a hackish sysfs
interface; now I'm cleaning it up for official submission. My current
plan is:

- each driver, in ata_port_operations, specifies a soft_reset and
hard_reset functions, which take ata_port* as a parameter
- in ata_scsi_pass_through, check for HARDRESET and SRST, and call
respective driver's soft/hard reset function

Now here's where I'm not quite certain on how to proceed. Another
developer has recommended that the reset be performed from an error
context, so that pre/post reset get called automatically. However,
there's a few issues, one of which is, as I was told, that the user
process will resume before the reset is complete. Thus the user sends
SG_IO and gets an immediate response, before the reset is finished,
whereas running the reset command directly blocks the user process
until the drive returns.

So the question is: should the driver simply call prereset, optionally
hardreset, softreset, and postreset, or set up the error handler
context to do it?

Thanks,

 - Yasha

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Recommendations on user-space soft/hardreset
  2007-07-18  0:34 ` Recommendations on user-space soft/hardreset Yasha Okshtein
@ 2007-07-18  0:45   ` Alan Cox
  2007-07-18  1:00     ` Yasha Okshtein
  2007-07-18  3:35   ` Tejun Heo
  1 sibling, 1 reply; 14+ messages in thread
From: Alan Cox @ 2007-07-18  0:45 UTC (permalink / raw)
  To: flyashi; +Cc: linux-ide

> - each driver, in ata_port_operations, specifies a soft_reset and
> hard_reset functions, which take ata_port* as a parameter

They already have them via the EH code.

> - in ata_scsi_pass_through, check for HARDRESET and SRST, and call
> respective driver's soft/hard reset function

Old IDE has an ioctl for it - it would be good to provide this for
compatibility as we have with some other needed ioctls.

> Now here's where I'm not quite certain on how to proceed. Another
> developer has recommended that the reset be performed from an error
> context, so that pre/post reset get called automatically. However,
> there's a few issues, one of which is, as I was told, that the user
> process will resume before the reset is complete. Thus the user sends
> SG_IO and gets an immediate response, before the reset is finished,
> whereas running the reset command directly blocks the user process
> until the drive returns.
> 
> So the question is: should the driver simply call prereset, optionally
> hardreset, softreset, and postreset, or set up the error handler
> context to do it?

I think you have to do the latter. I see no other way to get the locking
right, and the old IDE was horrible (and broken) because it tried to do
it in the user context. drivers/ide is a worked example of why *NOT* to
simply call the methods. The EH just needs triggering and can do the rest
sanely in a sensible context without adding new methods to the drivers.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Recommendations on user-space soft/hardreset
  2007-07-18  0:45   ` Alan Cox
@ 2007-07-18  1:00     ` Yasha Okshtein
  2007-07-18  1:18       ` Yasha Okshtein
  2007-07-18 12:54       ` Alan Cox
  0 siblings, 2 replies; 14+ messages in thread
From: Yasha Okshtein @ 2007-07-18  1:00 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-ide

As an example, I'll use the sata_sil24 driver, as that's what I'll be
using on my machine (until sata_mv comes around)

On 7/17/07, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> > - each driver, in ata_port_operations, specifies a soft_reset and
> > hard_reset functions, which take ata_port* as a parameter
>
> They already have them via the EH code.

You mean:

static const struct ata_port_operations sil24_ops = {
...
	.error_handler		= sil24_error_handler,
...
which then calls
	ata_do_eh(ap, ata_std_prereset, sil24_softreset, sil24_hardreset,
		  ata_std_postreset);

How to then specify if you just need a softreset? My understanding is
all those functions get called.

>
> > - in ata_scsi_pass_through, check for HARDRESET and SRST, and call
> > respective driver's soft/hard reset function
>
> Old IDE has an ioctl for it - it would be good to provide this for
> compatibility as we have with some other needed ioctls.

Well, the SAT way of specifying soft/hardresets I found at [1] on page
104, and the basis for this is already in libata, just not
implemented: see ata_scsi_map_proto. Implementing it there seems more
compatible with the standard.

> > So the question is: should the driver simply call prereset, optionally
> > hardreset, softreset, and postreset, or set up the error handler
> > context to do it?
>
> I think you have to do the latter. I see no other way to get the locking
> right, and the old IDE was horrible (and broken) because it tried to do
> it in the user context. drivers/ide is a worked example of why *NOT* to
> simply call the methods. The EH just needs triggering and can do the rest
> sanely in a sensible context without adding new methods to the drivers.
>

Ugh.. I figured, I was just hoping I wouldn't have to deal with that.
Any idea on what happens to the user process (blocking, etc.) during
error handling? Surely if a disk needs to be hardreset during a normal
error, the user process doesn't hang for up to 30 seconds?

 - Yasha

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Recommendations on user-space soft/hardreset
  2007-07-18  1:00     ` Yasha Okshtein
@ 2007-07-18  1:18       ` Yasha Okshtein
  2007-07-18 12:54       ` Alan Cox
  1 sibling, 0 replies; 14+ messages in thread
From: Yasha Okshtein @ 2007-07-18  1:18 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-ide

Sorry forgot to link to http://www.t10.org/drafts.htm , one of which is:
http://www.t10.org/ftp/t10/drafts/sat/sat-r09.pdf

Page 104 was what I was following for my initial implementation plan.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Recommendations on user-space soft/hardreset
  2007-07-18  0:34 ` Recommendations on user-space soft/hardreset Yasha Okshtein
  2007-07-18  0:45   ` Alan Cox
@ 2007-07-18  3:35   ` Tejun Heo
  2007-07-18  4:04     ` Yasha Okshtein
  1 sibling, 1 reply; 14+ messages in thread
From: Tejun Heo @ 2007-07-18  3:35 UTC (permalink / raw)
  To: flyashi; +Cc: linux-ide

Yasha Okshtein wrote:
> I need to send soft and/or hard resets from userspace.

Actually, you can do it by requesting manual rescan of the SCSI host.
"echo - - - > /sys/class/scsi_host/hostX/scan".

-- 
tejun

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Recommendations on user-space soft/hardreset
  2007-07-18  3:35   ` Tejun Heo
@ 2007-07-18  4:04     ` Yasha Okshtein
  2007-07-18  4:15       ` Tejun Heo
  0 siblings, 1 reply; 14+ messages in thread
From: Yasha Okshtein @ 2007-07-18  4:04 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide

Well ideally this should work with a port multiplier to soft/hardreset
only one disk behind the multiplier. Also, this again doesn't allow
the user to specify soft or hard reset - I believe rescanning forces
hardresets. Fully implementing the SATA spec, which should eventually
be done anyway, seems like a cleaner solution.

On 7/17/07, Tejun Heo <htejun@gmail.com> wrote:
> Yasha Okshtein wrote:
> > I need to send soft and/or hard resets from userspace.
>
> Actually, you can do it by requesting manual rescan of the SCSI host.
> "echo - - - > /sys/class/scsi_host/hostX/scan".
>
> --
> tejun
>


-- 
"I have never let my schooling interfere with my education."
  - Samuel Langhorne Clemens

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Recommendations on user-space soft/hardreset
  2007-07-18  4:04     ` Yasha Okshtein
@ 2007-07-18  4:15       ` Tejun Heo
  2007-07-18  5:01         ` Yasha Okshtein
  0 siblings, 1 reply; 14+ messages in thread
From: Tejun Heo @ 2007-07-18  4:15 UTC (permalink / raw)
  To: flyashi; +Cc: linux-ide

Yasha Okshtein wrote:
> Well ideally this should work with a port multiplier to soft/hardreset
> only one disk behind the multiplier.

You can do that too.  Just do 'echo x - -' where x corresponds to the
PMP port number.  On older versions it's 'echo - x -'.

> Also, this again doesn't allow
> the user to specify soft or hard reset - I believe rescanning forces
> hardresets. Fully implementing the SATA spec, which should eventually
> be done anyway, seems like a cleaner solution.

It defaults to softreset.

-- 
tejun

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Recommendations on user-space soft/hardreset
  2007-07-18  4:15       ` Tejun Heo
@ 2007-07-18  5:01         ` Yasha Okshtein
  2007-07-18  5:08           ` Tejun Heo
  0 siblings, 1 reply; 14+ messages in thread
From: Yasha Okshtein @ 2007-07-18  5:01 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide

On 7/17/07, Tejun Heo <htejun@gmail.com> wrote:
> Yasha Okshtein wrote:
> > Well ideally this should work with a port multiplier to soft/hardreset
> > only one disk behind the multiplier.
>
> You can do that too.  Just do 'echo x - -' where x corresponds to the
> PMP port number.  On older versions it's 'echo - x -'.
Nice, thanks!

> > Also, this again doesn't allow
> > the user to specify soft or hard reset - I believe rescanning forces
> > hardresets. Fully implementing the SATA spec, which should eventually
> > be done anyway, seems like a cleaner solution.
>
> It defaults to softreset.

That still leaves the original problem of hardresets :)

 - yasha

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Recommendations on user-space soft/hardreset
  2007-07-18  5:01         ` Yasha Okshtein
@ 2007-07-18  5:08           ` Tejun Heo
  2007-07-18  6:13             ` Yasha Okshtein
  0 siblings, 1 reply; 14+ messages in thread
From: Tejun Heo @ 2007-07-18  5:08 UTC (permalink / raw)
  To: flyashi; +Cc: linux-ide

Yasha Okshtein wrote:
>> It defaults to softreset.
> 
> That still leaves the original problem of hardresets :)

Yeah, I know, but with all other things served well by SCSI scan
request, I don't really think another reset request mechanism is too
compelling.  After all, why do you care whether SRST or HRST is used?
It's a reset anyway.

-- 
tejun

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Recommendations on user-space soft/hardreset
  2007-07-18  5:08           ` Tejun Heo
@ 2007-07-18  6:13             ` Yasha Okshtein
  0 siblings, 0 replies; 14+ messages in thread
From: Yasha Okshtein @ 2007-07-18  6:13 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide

On 7/17/07, Tejun Heo <htejun@gmail.com> wrote:
> After all, why do you care whether SRST or HRST is used?
> It's a reset anyway.

The softreset doesn't do what I need, which is to firmware upgrade a
certain drive model. While reloading the module does work, this takes
a while given the number of disks per machine (and lots of machines).

I've got a (hackish) way to do what I need, but I was hoping someone
else out there other than me needed a better way. And as it stands,
libata's implementation of the pass-through spec is incomplete.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Recommendations on user-space soft/hardreset
  2007-07-18  1:00     ` Yasha Okshtein
  2007-07-18  1:18       ` Yasha Okshtein
@ 2007-07-18 12:54       ` Alan Cox
  2007-07-18 16:49         ` Yasha Okshtein
  1 sibling, 1 reply; 14+ messages in thread
From: Alan Cox @ 2007-07-18 12:54 UTC (permalink / raw)
  To: flyashi; +Cc: linux-ide

> You mean:
> 
> static const struct ata_port_operations sil24_ops = {
> ...
> 	.error_handler		= sil24_error_handler,
> ...
> which then calls
> 	ata_do_eh(ap, ata_std_prereset, sil24_softreset, sil24_hardreset,
> 		  ata_std_postreset);
> 
> How to then specify if you just need a softreset? My understanding is
> all those functions get called.

The neccessary parts get called from libata-eh based upon the flags set
by the error code to indicate how to recover.

> Ugh.. I figured, I was just hoping I wouldn't have to deal with that.
> Any idea on what happens to the user process (blocking, etc.) during
> error handling? Surely if a disk needs to be hardreset during a normal
> error, the user process doesn't hang for up to 30 seconds?

It stalls.

Alan

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Recommendations on user-space soft/hardreset
  2007-07-18 12:54       ` Alan Cox
@ 2007-07-18 16:49         ` Yasha Okshtein
  0 siblings, 0 replies; 14+ messages in thread
From: Yasha Okshtein @ 2007-07-18 16:49 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-ide

On 7/18/07, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> The neccessary parts get called from libata-eh based upon the flags set
> by the error code to indicate how to recover.

I see... now let me see if I have this straight:
- ata_scsi_pass_thru checks and sees that it's a (soft,hard)reset
- sets up eh_info.action with either ATA_EH_HARDRESET or ATA_EH_SOFTRESET
- calls ata_port_schedule_eh(ap);

>From there, I think the error handler gets queued, but the user
process returns. The other option for the last step would be to call
the driver's error_handler directly.

This method seems to me like a better solution.

 - Yasha

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Recommendations on user-space soft/hardreset
@ 2007-07-20 15:14 Fajun Chen
  2007-07-22 12:20 ` Tejun Heo
  0 siblings, 1 reply; 14+ messages in thread
From: Fajun Chen @ 2007-07-20 15:14 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide@vger.kernel.org

Yasha Okshtein wrote:
> I need to send soft and/or hard resets from userspace.

>>Actually, you can do it by requesting manual rescan of the SCSI host.
>>"echo - - - > /sys/class/scsi_host/hostX/scan"

I've been using this approach to spin up a PATA drive. However,  I
have not figured out a way to return user scan result from kernel.
For instance, how can I tell if the scan failed at reset or Identify
Device from user space?

Thanks,
Fajun

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Recommendations on user-space soft/hardreset
  2007-07-20 15:14 Fajun Chen
@ 2007-07-22 12:20 ` Tejun Heo
  0 siblings, 0 replies; 14+ messages in thread
From: Tejun Heo @ 2007-07-22 12:20 UTC (permalink / raw)
  To: Fajun Chen; +Cc: linux-ide@vger.kernel.org

Fajun Chen wrote:
> Yasha Okshtein wrote:
>> I need to send soft and/or hard resets from userspace.
> 
>>> Actually, you can do it by requesting manual rescan of the SCSI host.
>>> "echo - - - > /sys/class/scsi_host/hostX/scan"
> 
> I've been using this approach to spin up a PATA drive. However,  I
> have not figured out a way to return user scan result from kernel.
> For instance, how can I tell if the scan failed at reset or Identify
> Device from user space?

Hmm... As it currently stands, you cannot.

-- 
tejun

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-07-22 12:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <6b01c6170707171723p4fdae403hf5b605fce4595b7@mail.gmail.com>
2007-07-18  0:34 ` Recommendations on user-space soft/hardreset Yasha Okshtein
2007-07-18  0:45   ` Alan Cox
2007-07-18  1:00     ` Yasha Okshtein
2007-07-18  1:18       ` Yasha Okshtein
2007-07-18 12:54       ` Alan Cox
2007-07-18 16:49         ` Yasha Okshtein
2007-07-18  3:35   ` Tejun Heo
2007-07-18  4:04     ` Yasha Okshtein
2007-07-18  4:15       ` Tejun Heo
2007-07-18  5:01         ` Yasha Okshtein
2007-07-18  5:08           ` Tejun Heo
2007-07-18  6:13             ` Yasha Okshtein
2007-07-20 15:14 Fajun Chen
2007-07-22 12:20 ` 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).