linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robert Hancock <hancockr@shaw.ca>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Tejun Heo <htejun@gmail.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	ide <linux-ide@vger.kernel.org>,
	l.genoni@oltrelinux.com
Subject: Re: something strange in libata-core.c for kernel 2.6.22-rc3
Date: Mon, 21 May 2007 12:14:58 -0600	[thread overview]
Message-ID: <4651E1A2.5000703@shaw.ca> (raw)
In-Reply-To: <20070521121537.48dd2b2c@the-village.bc.nu>

Alan Cox wrote:
>> Yeah, that's consistent to what I've seen on my machine which is a
>> variant of A8N.  No matter what value I through at _STM, _GTM just
>> echoed the result thus always leading to 80c configuration.
>>
>>> I guess this means that what we have to do is trust that the BIOS set up
>>> a reasonable mode and base the cable detect on that (either by reading
>>> back the boot-up controller registers, or by calling GTM). I imagine
>>> this is what the Windows default IDE driver is doing (just using the
>>> boot-up mode and feeding it back using GTM/STM on suspend/resume cycles).
>> Alan, what do you think?
> 
> Interesting, sounds like it is still useful rather than just reading the
> registers as the GTM/STM seem to survive resume cycles which drive config
> may not (eg if the driver is loaded after a s2ram/resume.

I don't think that case is handled in this BIOS anyway - if you call GTM 
after resume without previously calling STM, it's just going to read 
whatever random values are in the controller and give you timings based 
on that, which presumably will be junk.

It looks like the main purpose for what it's doing with saving those 
registers in the _PTS method is to save and restore a couple of 
controller registers called ID20 (PCI config space offset 0x50, 16 bits) 
and ID22 (PCI config space offset 0x5C, 32 bits) which aren't otherwise 
used in the AML. According to pata_amd, for the AMD IDE interface the 
former is some reserved bits as well as the cable detect bits, while the 
latter is the cycle time and address setup time register. Presumably 
those aren't really the cable detect bits though, since the detection 
based on those bits in pata_amd doesn't really work..

> If it just echoes back we should also be able to detect this by using
> knowingly invalid values.

Well, this implementation doesn't purely echo back the same values, it 
echoes back values derived from what the controller was actually set to, 
so I imagine if you put in something ridiculous it would come back with 
the closest possible mode that it was set to (PIO mode 0, etc.)

I suspect the implementation we would need to use (which doesn't depend 
on anything not given in the spec) would be:

-On driver load, execute _GTM to get the timing mode the BIOS had set. 
Assume this represents the fastest modes the controller supports, and 
set cable detect based on whether it includes UDMA modes > 2.

-If we decide to set a slower mode (speed down due to errors, etc.), set 
it using _STM and then read back the actual values that were set using 
_GTM (for possible use in suspend/resume).

-On resume after suspend, re-set the last mode using _STM followed by 
executing _GTF and running those commands.

This won't handle the case where the driver is loaded after the system 
was already suspended to RAM and resumed, however I don't know exactly 
how one could handle that in this situation..

-- 
Robert Hancock      Saskatoon, SK, Canada
To email, remove "nospam" from hancockr@nospamshaw.ca
Home Page: http://www.roberthancock.com/


  reply	other threads:[~2007-05-21 18:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <fa.MCe9nCgx+WnsHp+weZyM9LiDF0s@ifi.uio.no>
     [not found] ` <fa.rv8/6n3uBnAIoUHHNUW3eR7cJd8@ifi.uio.no>
     [not found]   ` <fa.LXy58QwLlPXDhsfVUU9kEfA3QbI@ifi.uio.no>
2007-05-20 17:18     ` something strange in libata-core.c for kernel 2.6.22-rc3 Robert Hancock
     [not found]     ` <fa.Ldjy2OubeKomZD0OV2gRm/wpUFo@ifi.uio.no>
2007-05-20 22:27       ` Robert Hancock
2007-05-21  8:34       ` Robert Hancock
2007-05-21  9:09         ` Tejun Heo
2007-05-21 11:15           ` Alan Cox
2007-05-21 18:14             ` Robert Hancock [this message]
2007-05-21  9:41         ` Jeff Garzik
     [not found] <Pine.LNX.4.64.0704181704270.1663@Phoenix.oltrelinux.com>
     [not found] ` <20070418162525.423b2e7e@the-village.bc.nu>
2007-05-20 12:40   ` l.genoni
2007-05-20 17:31     ` Tejun Heo

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=4651E1A2.5000703@shaw.ca \
    --to=hancockr@shaw.ca \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=htejun@gmail.com \
    --cc=l.genoni@oltrelinux.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).