(allocating non-cachable memory) (or More on the i82596)
Hrm... well, that's not the answer that I wanted, but it does explain a lot :-/
It sounds like you know a lot more about what's going on here, Paul, but since it sounds like we're in the same boat, I'm more than willing to help in whatever way I can (especially since I have nothing better to do until I get the ethernet controller working, and that just isn't happening without this fixed :)
And thanks for the heads up that setting PAGE_NO_CACHE doesn't work- I'd just tried disabling caches entirely and was about to go in and start mucking with lower level things- starting with a BAT entry :)
Back to the debugger...
--Gus
Quoted 22 lines · Paul White
Justin,
Quoted 1 line
From my recent experience, this does not work. We have a device on our
PCI bus which is DMAing to SDRAM, and so far I can't get anything to work without cache coherency support in the system controller.
If you find anything out, please let me know. I may end up adding a new memory queue for non-cacheable memory, and just use another BAT entry for some pre-defined amount of memory for a non-cacheable pool. A new flag to
kmalloc()could then be used to get non-cacheable memory. Does anyone know if anything like this already exists, or if theres a much easier way around this?? I should hopefully get cache coherency working, but we have been unable to so far. If I end up doing the work, I"ll post the patches here.Btw.. I attempted to disable cache, as well as simply set the RAM bat's to
PAGE_NO_CACHE, however this does not work because the PowerPC will throw alignment exceptions whenever a cache instruction is called on either a non-cached memory region, or if caching is disabled. Just wanted to give you a heads up on this.
Quoted 11 lines
Paul W.
Quoted 7 lines · Justin (Gus) Hurwitz
Did yo ever get a reply to this? That sounds like just what I want to do (well, it sounds just like what our vxworks code does to do what I want to do, which I guess is good enough).
TIA,
--Gus
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Justin,
I was able to get Data cache disabled today, after playing around with it for a while.
There were several things I had to do. Now, I don't recall what CPU you are using, so I'll just tell you what I found with mine.
First off, I'm using the 7410, which has 32 byte cache lines. Note that the 8xx and such have 16 byte cache lines. In my manual, under "Enabling and Disabling Data Cache", it states that the dcbz instruction will cause an alignment exception, and that all others are nop'd. So the first thing I did, was search for dcbz throughout my code, and I found two files that had several matches:
arch/ppc/kernel/misc.S
Line 380:
Inside clear_page. Here, I commented out the dcbz line, and added more of the stw lines to clear 32 bytes (it was set to only do 16, as on the 8xx its
only 16 bytes):
//#ifdef CONFIG_8xx
li r4, 0
1: stw r4, 0(r3)
stw r4, 4(r3)
stw r4, 8(r3)
stw r4, 12(r3)
stw r4, 16(r3)
stw r4, 20(r3)
stw r4, 24(r3)
stw r4, 28(r3)//#else
//1: dcbz 0,r3
//#endif
Line 426:
Inside copy_page. I left this one alone, as this one is called after Linux is running normally and the exception handler catches it. Note that the exception handler detects it was just a dcbz w/ data cache disabled, and returns normally. Doesn't kernel panic.
arch/ppc/lib/string.S
Line 170:
Inside cacheable_memzero, this one is called from MMU_init() where exceptions aren't enabled yet, so this one must be commented out, and changed to store 0's in its place, as such:
li r7,4
//#if !defined(CONFIG_8xx)
//10: dcbz r7,r6
//#else
10: stw r4, 0(r6)
stw r4, 4(r6)
stw r4, 8(r6)
stw r4, 12(r6)
stw r4, 16(r6)
stw r4, 20(r6)
stw r4, 24(r6)
stw r4, 28(r6)//#endif
Line 279:
Inside cacheable_memcpy. This one is also called after Linux is running normally, so I left this one alone as the exception handler catches it.
Line 483:
Inside copy_tofrom_user. This one, I just needed to comment out:
//#if !defined(CONFIG_8xx)
// dcbt r3,r4 // dcbz r11,r6
//#endif
After doing this, I then edited arch/ppc/mm/init.c Changed the RAM_PAGE define to:
#define RAM_PAGE (_PAGE_RW | _PAGE_NO_CACHE )
Then, in setbat() where it says "make IBAT same as DBAT":
} else {
/* make IBAT same as DBAT */
bat[0] = bat[1];
}I changed this to:
} else {
/* make IBAT same as DBAT */
bat[0] = bat[1];
bat[0].word[1] &= ~(_PAGE_NO_CACHE);
}This allowed Instruction cache to work still.
After this, I then wanted to be really sure data cache was disabled, so I editedarch/ppc/kernel/head.S:
Inside enable_caches, I changed the line:
ori r11,r11,HID0_DCE|HID0_ICE
to:
ori r11,r11,HID0_ICE
This just never enabled data cache, and everything worked fine (but slowly!).
Hope this information helps... Eventually I'll work up a patch with something likeCONFIG_NO_DCACHE, and maybe even CONFIG_WRITE_THRU on the cache and e-mail them out.
Paul W.
Quoted 10 lines · Justin (Gus) Hurwitz
Hrm... well, that's not the answer that I wanted, but it does explain a lot :-/
It sounds like you know a lot more about what's going on here, Paul, but since it sounds like we're in the same boat, I'm more than willing to help in whatever way I can (especially since I have nothing better to do until I get the ethernet controller working, and that just isn't happening without this fixed :)
Quoted 45 lines
And thanks for the heads up that setting
PAGE_NO_CACHEdoesn't work- I'd just tried disabling caches entirely and was about to go in and start mucking with lower level things- starting with a BAT entry :)Back to the debugger...
--GusQuoted 33 lines · Paul White
Justin,
Quoted 1 line
From my recent experience, this does not work. We have a device on our
PCI bus which is DMAing to SDRAM, and so far I can't get anything to work without cache coherency support in the system controller.
If you find anything out, please let me know. I may end up adding a new memory queue for non-cacheable memory, and just use another BAT entry for some pre-defined amount of memory for a non-cacheable pool. A new flag to
kmalloc()could then be used to get non-cacheable memory. Does anyone know if anything like this already exists, or if theres a much easier way around this?? I should hopefully get cache coherency working, but we have been unable to so far. If I end up doing the work, I"ll post the patches here.Btw.. I attempted to disable cache, as well as simply set the RAM bat's to
PAGE_NO_CACHE, however this does not work because the PowerPC will throw alignment exceptions whenever a cache instruction is called on either a non-cached memory region, or if caching is disabled. Just wanted to give you a heads up on this.Paul W.
Quoted 7 lines · Justin (Gus) Hurwitz
Did yo ever get a reply to this? That sounds like just what I want to do (well, it sounds just like what our vxworks code does to do what I want to do, which I guess is good enough).
TIA,
--Gus
-------------------------------------------------------------
Network Robots, Inc. /--\ Paul H. White
/ ____ \
4695 Chabot Dr. #200 / ( oo ) \ Software Developer
Pleasanton, CA 94588 / ---- \ Engineering
(925) 924-8600 \ ---- / (925) 580-4883
\ V--V /
\ /
\--/** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 9 lines · Paul White
Justin,
I was able to get Data cache disabled today, after playing around with it for a while.
There were several things I had to do. Now, I don't recall what CPU you are using, so I'll just tell you what I found with mine.
Quoted 6 lines
First off, I'm using the 7410, which has 32 byte cache lines. Note that the 8xx and such have 16 byte cache lines. In my manual, under "Enabling and Disabling Data Cache", it states that the dcbz instruction will cause an alignment exception, and that all others are nop'd. So the first thing I did, was search for dcbz throughout my code, and I found two files that had several matches:
I went through and made the same set of changes that you did- I am on a 603e, so I would expect the L1 cache behaviour to be about the same. Indeed, the kernel does boot properly, up until id decompresses the ramdisk. I am getting a crc error decompressing the ramdisk, however- presumably because of a problem with the caches. I'd like to set the MMU to caching inhibited to tighten up the processor's load and store ordering. I think that I only need to set this in the pte entries- the errors are only occuring after the MMU has been brought up. Irony of ironies, I know how to do this with the BATs, but not in the PTEs. It looks like there is a field in the PTE struct (in asm/mmu.h), but I can't find where that structure is initialised. It looks like, from my meandering through the kernel's memory management code that this might wee be a good step towards allowing chunks of non cachable memory to be allocated.
Thoughts?
--Gus
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
All true- except that I'm on a 603e :) It was someone else that was on the 4xx. I'm fairly sure that the 603e has 32 byte lines.
I think that I've hunted down all of the dcbz instructions, but I should go and check align.c. I've not had a chance to look through the book to see if there are other non-usable functions- I want to say that everything else is a nop on the 603e, but I'll double check when I get the chance.
Fingers crossed,
--Gus
Quoted 42 lines · Paul White
Justin,
I seen in a previous e-mail that you are using a 4xx proccessor. I'm assuming that this processor only has 16 bytes cache lines. When you went through the code I sent you, did you change it to only zero out 16 bytes instead of 32?
Also, Make sure in your CPU book that dcbz is the only instruction that can't be done when data cache is disabled.
You also may want to check
arch/ppc/kernel/align.cto make sure it still simply "returns" from an alignment excepetion caused by a dcbz. My tree (base line 2.4.4) has it. Otherwise, you may want to grep your code (in thearch/ppc/*, and ininclude/asm/*) for any other occurences of dcbz. Any at bootup time must be replaced with assembly instructions to zero out the memory locations, but ones that will happen during runtime should be OK if your alignment handler ignores them.Again, be sure to check your CPU manual. Maybe the 4xx CPU handles the data cache instructions differently from the 7410.
Also.. Make absolutely sure you made the right changes in the
arch/ppc/mm/init.cfile as well.SInce its crapping out uncompressing the ramdisk, I am assuming that the
copy_pagesorcopy_tofrom_userstuff isn't working right (Maybe you still have it zero'ing out 32 bytes instead of 16?)Paul W.
Quoted 11 lines · Justin (Gus) Hurwitz
Quoted 9 lines · Paul White
Justin,
I was able to get Data cache disabled today, after playing around with it for a while.
There were several things I had to do. Now, I don't recall what CPU you are using, so I'll just tell you what I found with mine.
Quoted 29 lines
Quoted 1 line
Quoted 1 line
First off, I'm using the 7410, which has 32 byte cache lines. Note that
the
Quoted 2 lines
Quoted 2 lines
8xx and such have 16 byte cache lines. In my manual, under "Enabling and Disabling Data Cache", it states that the dcbz instruction will
cause an
Quoted 1 line
Quoted 1 line
alignment exception, and that all others are nop'd. So the first thing
I did,
Quoted 22 lines
Quoted 2 lines
was search for dcbz throughout my code, and I found two files that had several matches:
I went through and made the same set of changes that you did- I am on a 603e, so I would expect the L1 cache behaviour to be about the same. Indeed, the kernel does boot properly, up until id decompresses the ramdisk. I am getting a crc error decompressing the ramdisk, however- presumably because of a problem with the caches. I'd like to set the MMU to caching inhibited to tighten up the processor's load and store ordering. I think that I only need to set this in the pte entries- the errors are only occuring after the MMU has been brought up. Irony of ironies, I know how to do this with the BATs, but not in the PTEs. It looks like there is a field in the PTE struct (in
asm/mmu.h), but I can't find where that structure is initialised. It looks like, from my meandering through the kernel's memory management code that this might wee be a good step towards allowing chunks of non cachable memory to be allocated.Thoughts?
--Gus
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Justin,
I seen in a previous e-mail that you are using a 4xx proccessor. I'm assuming that this processor only has 16 bytes cache lines. When you went through the code I sent you, did you change it to only zero out 16 bytes instead of 32?
Also, Make sure in your CPU book that dcbz is the only instruction that can't be done when data cache is disabled.
You also may want to check arch/ppc/kernel/align.c to make sure it still simply "returns" from an alignment excepetion caused by a dcbz. My tree (base line 2.4.4) has it. Otherwise, you may want to grep your code (in the arch/ppc/*, and in include/asm/*) for any other occurences of dcbz. Any at bootup time must be replaced with assembly instructions to zero out the memory locations, but ones that will happen during runtime should be OK if your alignment handler ignores them.
Again, be sure to check your CPU manual. Maybe the 4xx CPU handles the data cache instructions differently from the 7410.
Also.. Make absolutely sure you made the right changes in the arch/ppc/mm/init.c file as well.
SInce its crapping out uncompressing the ramdisk, I am assuming that the copy_pages or copy_tofrom_user stuff isn't working right (Maybe you still have it zero'ing out 32 bytes instead of 16?)
Paul W.
Quoted 5 lines · Justin (Gus) Hurwitz
Quoted 3 lines · Paul White
Justin,
Quoted 7 lines
Quoted 7 lines
I was able to get Data cache disabled today, after playing around with it for a while.
There were several things I had to do. Now, I don't recall what CPU you are using, so I'll just tell you what I found with mine.
First off, I'm using the 7410, which has 32 byte cache lines. Note that
the
Quoted 2 lines
Quoted 2 lines
8xx and such have 16 byte cache lines. In my manual, under "Enabling and Disabling Data Cache", it states that the dcbz instruction will
cause an
Quoted 1 line
Quoted 1 line
alignment exception, and that all others are nop'd. So the first thing
I did,
Quoted 18 lines
Quoted 2 lines
was search for dcbz throughout my code, and I found two files that had several matches:
I went through and made the same set of changes that you did- I am on a 603e, so I would expect the L1 cache behaviour to be about the same. Indeed, the kernel does boot properly, up until id decompresses the ramdisk. I am getting a crc error decompressing the ramdisk, however- presumably because of a problem with the caches. I'd like to set the MMU to caching inhibited to tighten up the processor's load and store ordering. I think that I only need to set this in the pte entries- the errors are only occuring after the MMU has been brought up. Irony of ironies, I know how to do this with the BATs, but not in the PTEs. It looks like there is a field in the PTE struct (in
asm/mmu.h), but I can't find where that structure is initialised. It looks like, from my meandering through the kernel's memory management code that this might wee be a good step towards allowing chunks of non cachable memory to be allocated.
Quoted 4 lines
Thoughts?
--Gus
-------------------------------------------------------------
Network Robots, Inc. /--\ Paul H. White
/ ____ \
4695 Chabot Dr. #200 / ( oo ) \ Software Developer
Pleasanton, CA 94588 / ---- \ Engineering
(925) 924-8600 \ ---- / (925) 580-4883
\ V--V /
\ /
\--/** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
Quoted 2 lines · Justin (Gus) Hurwitz
I think that I've hunted down all of the dcbz instructions, but I should go and check
align.c.
There is no reason to do this. The behavior of these instruction on the 603e aren't any different than other processors. If you know you are operating on I/O space, use the memset_io/memcpy_fromio()/memcpy_toio() and not the usual memory copy/set functions.
-- Dan
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/