 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Sun Sep 21, 2008 7:09 am Post subject: linux kernel memory allocation. |
|
|
That code allocates memory on PS3:
| Code: |
**
* ps3_mm_region_create - create a memory region in the vas
* @r: pointer to a struct mem_region to accept initialized values
* @size: requested region size
*
* This implementation creates the region with the vas large page size.
* @size is rounded down to a multiple of the vas large page size.
*/
static int ps3_mm_region_create(struct mem_region *r, unsigned long size)
{
int result;
unsigned long muid;
r->size = _ALIGN_DOWN(size, 1 << PAGE_SHIFT_16M);
DBG("%s:%d requested %lxh\n", __func__, __LINE__, size);
DBG("%s:%d actual %lxh\n", __func__, __LINE__, r->size);
DBG("%s:%d difference %lxh (%luMB)\n", __func__, __LINE__,
(unsigned long)(size - r->size),
(size - r->size) / 1024 / 1024);
if (r->size == 0) {
DBG("%s:%d: size == 0\n", __func__, __LINE__);
result = -1;
goto zero_region;
}
result = lv1_allocate_memory(r->size, PAGE_SHIFT_16M, 0,
ALLOCATE_MEMORY_TRY_ALT_UNIT, &r->base, &muid);
....
|
On my FW ( 1.9 ) that code works after main allocation:
result = lv1_allocate_memory( 6 * 1024 * 1024, 20,0,ALLOCATE_MEMORY_TRY_ALT_UNIT, &lpar, &muid);
ioremap ( and gpu_ioremap ) works for this lpar address.
So there are 6 free MiBs of memory, unused by Linux. Why? |
|
| Back to top |
|
 |
ps2devman
Joined: 09 Oct 2006 Posts: 265
|
Posted: Sun Sep 21, 2008 7:19 pm Post subject: |
|
|
Maybe a safety gap?
Allows future firmware update to have otheros bootstrap consumes a bit more? (for black listing or such...) |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Mon Sep 22, 2008 5:50 pm Post subject: |
|
|
Anyhow, it is interesting to test this code ( giving 6+ free MiBs to Linux ):
| Code: |
#define PAGE_SHIFT_1M 20
r->size = _ALIGN_DOWN(size, 1 << PAGE_SHIFT_1M);
result = lv1_allocate_memory(r->size, PAGE_SHIFT_1M, 0, ALLOCATE_MEMORY_TRY_ALT_UNIT, &r->base, &muid);
|
Otherwise it is possible to write driver for additional memory allocation. |
|
| Back to top |
|
 |
androvsky
Joined: 11 Nov 2007 Posts: 33
|
Posted: Tue Sep 23, 2008 2:33 am Post subject: |
|
|
| IronPeter, this is probably off-topic, but I've been wondering if the PS3 you're testing on has some PS2 hardware in it. It might be interesting if you stumbled across that... ;) |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Wed Sep 24, 2008 2:51 am Post subject: |
|
|
| I have no ideas about PS2 inside my PS3. Really no ideas :). |
|
| Back to top |
|
 |
IronPeter
Joined: 06 Aug 2007 Posts: 207
|
Posted: Mon Oct 13, 2008 4:32 pm Post subject: alloc_memory - gpu_ioremap - release_memory cheat |
|
|
I used memory chunk allocated by lv1_allocate_memory( 1 << 20, 20, 0, 0x04, &xdr_lpar, &muid );
The function lv1_gpu_context_iomap( context.handle, 0, xdr_lpar, 1 << 20, 0 ) returns 0. But RSX failed to write/read that memory. Why?
lv1_gpu_context_iomap( context.handle, 0, xdr_frame_buffer, 1 << 20, 0 ) works well for xdr frame buffer, it can be made visible both at GPU_IOIF and 0 addresses.
PS. I tried to test
1.) lv1_allocate_memory
2.) lv1_gpu_context_iomap
3.) lv1_release_memory
4.) some DMA transfers by GPU
I wanted to check GPU DMA protection (any access by CPU to released memory causes bus error ). But I failed at 2.) |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|