Skip to contentSkip to conversation

Why timer interrupt is disabled?

DISCUSSION andreev 3 participants 8 messages May 25, 2001 1 message not in the archive Memory technology devices (MTD)

lore
Share & tools
lore

andreev

author
#0 lore raw

Hi, list.
I have an Intel CFI compatible chip on my MIPS machine, which is mapped on to the physical memory .When i compiled linux-2.4.1 kernel with Intel CFI support, and booted my MIPS, linux hanged when i tried to read data from flash.

Then, i inserted debugging printk functions, and found that i read data insteed of status register from flash. ( Because my chip must be programmed with double word commands ). In this case, driver must return -EIO in do_read_1_by_16_onechip after time out. But it do not, because all interrupts were disabled before do_ftl_request called. In do_ftl_request i found commented out sti() function. Why it were commented out? I had a look to the current sourse in your CVS, and i found that sti() is still commented out. Where we have to enable interrupts? If driver works under the closed interrupts, why does it use the time_after and jiffies?
Can anybody tell me abouut it?

#1 lore raw
Quoted 5 lines · [email protected] said:

In do_ftl_request i found commented out sti() function. Why it were
commented out? I had a look to the current sourse in your CVS, and i found that sti() is still commented out. Where we have to enable interrupts? If driver works under the closed interrupts, why does it use the time_after and jiffies? Can anybody tell me abouut it?

You probably need to unlock the io_request_lock. But you probably shouldn't be using FTL anyway - why not just put JFFS or JFFS2 on the flash directly?

--
dwmw2

#3 lore raw
In reply to a message not in the archive
Quoted 3 lines · [email protected] said:

<br><br></pre></blockquote> I know that JFFS is the better choice, but I must use the FTL driver, because there is installed X-server on my flash <br> partition... <br>

I don't see the logic. The Compaq iPAQ works quite well with the X-server in the JFFS2 filesystem.

Quoted 2 lines

<br> I think that unlocking of the io_request_lock inside ftl driver
is not a good idea, because the do_ftl_request must be <br> atomic.

My understanding is that it's perfectly safe to drop the io_request_lock as long as we only look at the request at the head of the queue. There's no need for do_ftl_request to be atomic - and in fact it cannot be atomic because the flash read and write calls may sleep.

Quoted 3 lines

What about enabling all or only <br> timer interrupts inside do_ftl_request. Can you uncomment the sti() in ftl.c in your CVS version?<br> <br> <br> </body></html>

If you ensure that it's correct to do so, and provide a patch which releases the io_request_lock, then I'll certainly consider applying it.

--
dwmw2

#4 lore raw
Quoted 7 lines · David Woodhouse
Quoted 3 lines · [email protected] said:

I know that JFFS is the better choice, but
I must use the FTL driver, because there is installed X-server on my flash partition...

I don't see the logic. The Compaq iPAQ works quite well with the X-server in the JFFS2 filesystem.

I dont want to format my flash partition write now. Besides it doesnt matter. Of course i`ll use JFFS in the future.

Quoted 5 lines
Quoted 3 lines

I think that unlocking of the io_request_lock inside ftl driver is not a good idea, because the do_ftl_request must be atomic.

My understanding is that it's perfectly safe to drop the io_request_lock as long as we only look at the request at the head of the queue. There's no need for do_ftl_request to be atomic - and in fact it cannot be atomic because the flash read and write calls may sleep.

I think, if write call sleeps, than we must return. Do i wrong?
Locking of io_request_lock and disabling interrupts, are mading in
block devices common driver. I read the kernel-api documentation in Documentation/DocBook/kernel-api/r10011.html: " A global spin lock $io_request_lock must be held while manipulating the requests on the request queue."
Besides, if we unlock the io_request_lock and enable all interrupts
it might to occur this thing:
While we are reading or writing data to the flash, the timer interrupt is happens. Next, the schedule() called, and an other process begins to write or read data to the flash. Can you guarantee, that flash is protected by locks and "chips->state" inside the CFI driver? I mean: if we write the READ_STATUS command to flash inside context of first process, and trying to read data inside context of second process, than we read status, but not data.
In all cases we need to enable timer ticks, anywhere in flash. It is
the simplies way i think...

#5 lore raw
Quoted 5 lines · [email protected] said:

Locking of io_request_lock and disabling interrupts, are mading in
block devices common driver. I read the kernel-api documentation in Documentation/DocBook/kernel-api/r10011.html: " A global spin lock $io_request_lock must be held while manipulating the requests on the request queue."

Ah - but we're _not_ manipulating the requests on the request queue. We're servicing the request at the head of the queue, which is a special case - the queueing code knows that drivers are likely to be looking at the request at the head of the queue even while the io_request_lock is not held.

Quoted 3 lines · [email protected] said:

While we are reading or writing data to the flash, the timer interrupt
is happens. Next, the schedule() called, and an other process begins
to write or read data to the flash.

The kernel is not preemptively scheduled. Unless the first process explicitly calls schedule(), it's not going to lose the CPU. Only processes in user mode are scheduled from the timer IRQ.

--
dwmw2

#6 lore raw
Quoted 3 lines · David Woodhouse

The kernel is not preemptively scheduled. Unless the first process explicitly calls schedule(), it's not going to lose the CPU. Only processes in user mode are scheduled from the timer IRQ.

Is it not dangerous to assume that the kernel is non-preemptive? MTD is after all most likely to be used in a real-time system, which may very well have a different scheduler from the common/garden variety Linux.

Cheers,

Signature · 3 lines
Herman Oosthuysen
Phone: 403+569-5687
E-mail: [email protected]
#7 lore raw
In reply to David Woodhouse
Quoted 5 lines · David Woodhouse

Ah - but we're _not_ manipulating the requests on the request queue. We're servicing the request at the head of the queue, which is a special case - the queueing code knows that drivers are likely to be looking at the request at the head of the queue even while the io_request_lock is not held.

The kernel is not preemptively scheduled. Unless the first process explicitly calls schedule(), it's not going to lose the CPU. Only processes in user mode are scheduled from the timer IRQ.

Oh yeah, i've got it... you absolutely right, the flash driver will never support requests manipulating, so we can don't care about the io_request_lock holding, and kernel is really preemptively. So, we can unlock the io_request_lock in ftl.c, but what about double unlocking? Or, do you want to lock it back after proceeding request :) Is there any conflicts, when we try to unlock already unlocked lock?

#8 lore raw
Quoted 4 lines · [email protected] said:

reemptively. So, we can unlock the io_request_lock in ftl.c, but what about double unlocking? Or, do you want to lock it back after proceeding request :) Is there any conflicts, when we try to unlock already unlocked lock?

You have to lock it again before returning.

But you really shouldn't be taking my advice on how to write block devices. I've been trying to avoid it :)

--
dwmw2