Skip to contentSkip to conversation

Interrupt handling....

DISCUSSION Matthew Dharm 3 participants 10 messages Sep 4, 2002 – Sep 5, 2002 1 message not in the archive MIPS

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Okay... I think I've got a problem that isn't covered by the usual examples.

I'm now trying to implment a second-level interrupt demuxer. My exception handler, when it sees a certain bit set in the CP0_CAUSE register set, attempts to read from the second-level controller. The problem is, that code looks like this:

	li	t0, 0xfc000000
	lb	t1, 0xc(t0)

Which, as you can see, attempts to access address 0xfc00000c. And then I get:

Unable to handle kernel paging request at virtual address fc00000c,

epc == 801af2ac, ra == 80102eb8
Oops in fault.c::do_page_fault, line 206:

I'm guessing I'm in trouble here. My instincts tell me the the only way out of this might be to add a wired TLB entry to make certain I can always access physical address 0xfc00000c... but I'm hoping there is a better solution than tying up a TLB entry like that. After all, isn't that what ioremap is supposed to do?

Matt

--

Matthew D. Dharm                            Senior Software Designer
Momentum Computer Inc.                      1815 Aston Ave.  Suite 107
(760) 431-8663 X-115                        Carlsbad, CA 92008-7310
Momentum Works For You                      www.momenco.com
Quoted 51 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Jun Sun
Sent: Thursday, August 29, 2002 1:46 PM
To: Matthew Dharm
Cc: Linux-MIPS
Subject: Re: Interrupt handling....

Quoted 1 line · Matthew Dharm

I've taken it upon myself to re-write some interrupt

handling code.

Quoted 2 lines

It's a mess, and it needs cleaning.

That is usually a right attitude to start ... :=)

Quoted 2 lines

An interrupt handler must be registered with

set_except_vector(0, ...)

Quoted 1 line

which must return a numeric code in the range of

0..NR_IRQS -- it can

Quoted 3 lines

do this in any way it wants, including limited function calls (ie there is a stack in place).

Interrupt is setup throught request_irq()/setup_irq(). set_except_vector()
for setting exception handlers, which is different from interrupts.

Quoted 2 lines

The irq_desc array of irq_desc_t structures is where the magic happens. The value returned by the interrupt handler is

used as an

Quoted 2 lines

index into this array to do the dispatch a specific handler. The 'status' and 'action' fields are pretty much

self-explanatory. The

Quoted 1 line

'handler' field seems to point to a set of function

pointers used for

Quoted 1 line

enabling/disabling the IRQ. But what is 'depth' for?

Boards seem to

Quoted 1 line

set it to either 0 or 1 commonly, but I don't see why.

For nested disabling and enabling of interrupts.

Quoted 2 lines

I also don't
see how IRQ sharing is accomplished...

Yes, it is there. See do_IRQ() and a sub-routine
handle_event() (or something
like that)

Quoted 5 lines
Quoted 1 line

Is this pretty much how it all works?

I have a more detailed description in my porting guide.

http://linux.junsun.net/porting-howto/porting-howto.html#cha

pter-interrupt

Jun

#2 lore raw

Matthew,

Quoted 2 lines

Okay... I think I've got a problem that isn't covered by the usual examples.

Possibly this is too simple an answer and is stuff you know quite well already...

Quoted 1 line

Which, as you can see, attempts to access address 0xfc00000c.

But that address is in the MIPS CPU's 'kseg2' region. Addresses there are always translated by the TLB, and you haven't got an entry.

Registers from things like the 2nd level interrupt controller are memory mapped I/O locations, and you need to do an uncached access to the appropriate physical address.

Most MIPS hardware has registers mapped between 0-512Mbyte (0-0x1fff.ffff) physical, because a MIPS CPU can do uncached accesses to that using the 'kseg1' window, which occupies the

0xa000.0000-0xbfff.ffff (CPU virtual address)
0x0000.0000-0x1fff.ffff (physical address).

There are macros defined for translating a physical address into a kseg1 address (just add 0xa000.0000, really).

You could read the book ("See MIPS Run")...

Signature · 5 lines
Dominic Sweetman, 
MIPS Technologies (UK) - formerly Algorithmics
The Fruit Farm, Ely Road, Chittering, CAMBS CB5 9PH, ENGLAND
phone: +44 1223 706200 / fax: +44 1223 706250 / direct: +44 1223 706205
http://www.algor.co.uk
#3 lore raw
Quoted 8 lines · Dominic Sweetman
Quoted 1 line

Which, as you can see, attempts to access address 0xfc00000c.

But that address is in the MIPS CPU's 'kseg2' region. Addresses there are always translated by the TLB, and you haven't got an entry.

Registers from things like the 2nd level interrupt controller are memory mapped I/O locations, and you need to do an uncached access to the appropriate physical address.

As I understand 0xfc00000c is the physical address. Thus you cannot
reach it via KSEG0/1 (although you may use XKPHYS to get there in the 64-bit mode). Still ioremap() already handles the case mapping the area requested in the KSEG2 space, so it should work just fine.

Quoted 6 lines

Most MIPS hardware has registers mapped between 0-512Mbyte (0-0x1fff.ffff) physical, because a MIPS CPU can do uncached accesses to that using the 'kseg1' window, which occupies the

0xa000.0000-0xbfff.ffff (CPU virtual address)
0x0000.0000-0x1fff.ffff (physical address).

As I understand this is an exception. Possibly the system supports more
than 512MB of RAM and the designers wanted to avoid holes.

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +
#4 lore raw
Quoted 7 lines · Maciej W. Rozycki
Quoted 5 lines · Dominic Sweetman
Quoted 1 line

Which, as you can see, attempts to access address 0xfc00000c.

But that address is in the MIPS CPU's 'kseg2' region. Addresses there are always translated by the TLB, and you haven't got an entry.

Quoted 8 lines
Quoted 3 lines

Registers from things like the 2nd level interrupt controller are memory mapped I/O locations, and you need to do an uncached access to the appropriate physical address.

As I understand 0xfc00000c is the physical address. Thus you cannot
reach it via KSEG0/1 (although you may use XKPHYS to get there in the 64-bit mode). Still ioremap() already handles the case mapping the area requested in the KSEG2 space, so it should work just fine.

This is the case. The board itself has up to 1G of SDRAM. Most of the boards we sell have a minimum of 512MB. So our I/O (PCI, external devices, etc.) all have physical addresses in the high-end of the address space.

64-bit mode would be great... and we plan to go there eventually. But, for now, 32-bit is where we are.

Quoted 9 lines
Quoted 6 lines

Most MIPS hardware has registers mapped between 0-512Mbyte (0-0x1fff.ffff) physical, because a MIPS CPU can do uncached accesses to that using the 'kseg1' window, which occupies the

0xa000.0000-0xbfff.ffff (CPU virtual address)
0x0000.0000-0x1fff.ffff (physical address).

As I understand this is an exception. Possibly the system supports more
than 512MB of RAM and the designers wanted to avoid holes.

This is exactly the case. Our organization focuses on high-end computing platforms. 512MB is becoming a minimum amount of memory for us.

Matt

Signature · 2 lines
Matthew Dharm                              Work: [email protected]
Senior Software Designer, Momentum Computer
#7 lore raw
In reply to Dominic Sweetman
Quoted 8 lines · Dominic Sweetman

Matthew,

Quoted 2 lines

Okay... I think I've got a problem that isn't covered by the usual examples.

Possibly this is too simple an answer and is stuff you know quite well already...

Yeah, it is. See my response to Maciej's posting....

Quoted 4 lines
Quoted 1 line

Which, as you can see, attempts to access address 0xfc00000c.

But that address is in the MIPS CPU's 'kseg2' region. Addresses there are always translated by the TLB, and you haven't got an entry.

It's also the physical address.

And this is the heart of the problem. I set up an ioremap, so I thought that the TLB exception handler would fix this for me. It looks like that code won't do anything if the exception was generated from an interrupt... Or am I reading it wrong? I'm not an expert on the TLB code...

Quoted 1 line

You could read the book ("See MIPS Run")...

I read it quite some time ago. My copy got very dog-eared before I had the majority of the information committed to memory. Nice book, BTW.

Matt

Signature · 2 lines
Matthew Dharm                              Work: [email protected]
Senior Software Designer, Momentum Computer
#8 lore raw
Quoted 4 lines · Matthew Dharm

And this is the heart of the problem. I set up an ioremap, so I thought that the TLB exception handler would fix this for me. It looks like that code won't do anything if the exception was generated from an interrupt... Or am I reading it wrong? I'm not an expert on the TLB code...

The kernel memory is unswappable so a PTE is always available. If the
TLB refill handler cannot fetch it for some reason, then there is a bug somewhere. It might be helpful if you narrowed it down a bit -- refills work correctly for modules, including interrupt handlers, and they reside in KSEG2.

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +
#9 lore raw

Okay... What type of information do you need?

Matt

--

Matthew D. Dharm                            Senior Software Designer
Momentum Computer Inc.                      1815 Aston Ave.  Suite 107
(760) 431-8663 X-115                        Carlsbad, CA 92008-7310
Momentum Works For You                      www.momenco.com
Quoted 33 lines

-----Original Message-----
From: Maciej W. Rozycki [mailto:[email protected]]
Sent: Wednesday, September 04, 2002 10:03 AM
To: Matthew Dharm
Cc: Dominic Sweetman; Jun Sun; Linux-MIPS
Subject: Re: Interrupt handling....

Quoted 1 line · Matthew Dharm

And this is the heart of the problem. I set up an

ioremap, so I thought

Quoted 1 line

that the TLB exception handler would fix this for me. It

looks like that

Quoted 1 line

code won't do anything if the exception was generated

from an interrupt...

Quoted 1 line

Or am I reading it wrong? I'm not an expert on the TLB code...

The kernel memory is unswappable so a PTE is always
available. If the
TLB refill handler cannot fetch it for some reason, then there is a bug
somewhere. It might be helpful if you narrowed it down a bit -- refills
work correctly for modules, including interrupt handlers, and they reside
in KSEG2.

--

(quoted diff) +3 -0
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +
#5 lore raw
In reply to Matthew Dharm
Quoted 8 lines · Matthew Dharm
Quoted 4 lines

As I understand 0xfc00000c is the physical address. Thus you cannot
reach it via KSEG0/1 (although you may use XKPHYS to get there in the 64-bit mode). Still ioremap() already handles the case mapping the area requested in the KSEG2 space, so it should work just fine.

This is the case. The board itself has up to 1G of SDRAM. Most of the boards we sell have a minimum of 512MB. So our I/O (PCI, external devices, etc.) all have physical addresses in the high-end of the address space.

Well, next time, get your board designers to think before they map...

It's generally better to map some DRAM low (for boot ROMs and other stupid programs you don't want to make big-address aware), then remap the whole DRAM to some very high address for Linux. Much better than forcing you to use the TLB (or XKPHYS, if you've a 64-bit CPU) to get at I/O.

Quoted 1 line

64-bit mode would be great...

Bear in mind that there *isn't a 64-bit mode*. Privileged code (which is everything except Linux applications) can always run 64-bit instructions; all addresses are 64-bits really, it's just the sign-extension of the registers which makes you think you've got 32-bit pointers. Usually a 64-bit CPU can access XKPHYS any time it can access I/O registers.

Signature · 5 lines
Dominic Sweetman, 
MIPS Technologies (UK) - formerly Algorithmics
The Fruit Farm, Ely Road, Chittering, CAMBS CB5 9PH, ENGLAND
phone: +44 1223 706200 / fax: +44 1223 706250 / direct: +44 1223 706205
http://www.algor.co.uk
#10 lore raw
In reply to Matthew Dharm
Quoted 1 line · Matthew Dharm

Okay... What type of information do you need?

Well, first check if a PTE is indeed installed by ioremap() in the table.
If so, the what happens at the access time -- what exceptions, what are the contents of the related registers, what does exist in the TLB, etc. You don't need to go to the IRQ handler at first -- it might be easier to get such things if you deliberately access the location from elsewhere, e.g. from the setup code right after ioremap().

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +
#6 lore raw
In reply to Dominic Sweetman
Quoted 7 lines · Dominic Sweetman

Well, next time, get your board designers to think before they map...

It's generally better to map some DRAM low (for boot ROMs and other stupid programs you don't want to make big-address aware), then remap the whole DRAM to some very high address for Linux. Much better than forcing you to use the TLB (or XKPHYS, if you've a 64-bit CPU) to get at I/O.

Hmm, what's the deal? Other processors always use MMU to access iomem...

Quoted 6 lines

Bear in mind that there *isn't a 64-bit mode*. Privileged code (which is everything except Linux applications) can always run 64-bit instructions; all addresses are 64-bits really, it's just the sign-extension of the registers which makes you think you've got 32-bit pointers. Usually a 64-bit CPU can access XKPHYS any time it can access I/O registers.

Well, it's mostly a programming convention. Without going into details,
arch/mips is the 32-bit mode and arch/mips64 is the 64-bit one. The usual approximation is the state of cp0.kx, even though 64-bit operations do indeed work when ~cp0.kx.

Signature · 3 lines
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email protected], PGP key available        +