Tips for random disk lockups

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Tips for random disk lockups

Post by bewing »

I would think that just about all of us have run into random disk lockups at one time or another as we build our OSes? I did a search, but couldn't find any threads giving suggestions on any of the (millions, of course) things that could be wrong. -- But I thought that such a thread might give future users (or even me!) a glimmer of an idea of what might be wrong when we run into the problem (again).

I can even give one tip that hung me up for a bit, a few months ago: I didn't realize back then that I needed to wait for an interrupt, (or alternately for the "busy" flag to clear) -- in between EVERY SINGLE sector that I was reading or writing in PIO mode. I was under the impression that once I issued the command, I'd have to wait for the disk to become ready, and then the whole thing would be streamed in one gulp ... silly, I know. :wink:


But now I've run into it again. I just moved from Bochs (where everything was running perfectly) onto *gasp* real hardware. And now I get random disk lockups -- it seems after about 10 or 20 reads/writes.

So: I'd love to hear some examples of what caused disk lockups for all the rest of you, and maybe it'll shorten my debugging time. I hate debugging random stuff. :x
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

I've noticed that between bochs and real hardware for example the hardware sometimes issues a different number of IRQs for the same operation. This was one of the problems I had getting the floppy driver to work on real hardware, bochs generated an IRQ when the floppy drive reset and real hardware didn't. I'd keep an eye out for stuff like that.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

OK, this incidence of disk lockups was caused by a hardware timing problem. I could read all day long, just so long as I never did any writes. It was the writes that would kill me (after a delay, usually).

Hardware: AMD K2/266Mhz - non-ATX mbrd (ie. older) - IBM 1GB non-UDMA of any sort ATA disk.

The ATA6 specification says that you are intended to use REP INSW and REP OUTSW to copy data in PIO mode. For reading (REP INSW) this works. For writing, it does not, on this hardware setup. I needed to do a loop:

Code: Select all

.odlylp:
	call io_delay
	outsw		; dump one word from esi
	dec ecx
	jg short .odlylp
If I tried to use REP OUTSW, sometimes the disk would lock up right then, sometimes the write would work correctly, sometimes the write would fail gracefully -- and sometimes the write would fail invisibly, and the NEXT disk access would lock up.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Hardware: AMD K2
That must've been a typo, that chip doesn't exist...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Combuster wrote:
Hardware: AMD K2
That must've been a typo, that chip doesn't exist...
It was a nickname for AMD's K6-2 models.. I know a few people who call it that, stop being so damn pedantic ;)
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Post Reply