Topic
  • 4 replies
  • Latest Post - ‏2008-10-21T04:36:22Z by SystemAdmin
SystemAdmin
SystemAdmin
10114 Posts

Pinned topic Accessing ps->MFC_LSA (spe_mfc_command_area_t) creates hang.

‏2008-10-15T09:11:46Z |
Hi,

I am tyring to do a simple experiment for PPE initiated DMA (using the MFC of one of the SPE) on a cell simulator. Below is the code snippet for the same.

main()
{
int *src=NULL, *dst=NULL,cmd, rid, tid;
volatile unsigned int status = 0;
unsigned int pte_val=0;
volatile spe_mfc_command_area_t *ps = NULL;
spe_context_ptr_t speid=0;

tid = 0; rid = 0; cmd = 0x40;
src = (int *)memalign(128, 128);
dst = (int *)memalign(128, 128);
memset(src, 0xba, 128);
memset(dst, 0x0, 128);
pte_val = (unsigned int)src;
printf("src = %p", src);
printf("speid pointer %x \n", speid);
speid = spe_context_create (SPE_MAP_PS, NULL) ;
printf("speid pointer %x \n", speid);
ps = (spe_mfc_command_area_t *) spe_ps_area_get (speid, SPE_MFC_COMMAND_AREA);
do {
(ps->MFC_LSA) = (unsigned int)0x100; // This line creates a hang!!
(ps->MFC_EAH) = (unsigned int)0;
(ps->MFC_EAL) = (unsigned int)pte_val;
(ps->MFC_Size_Tag) = 0x40000;
(ps->MFC_ClassID_CMD) = (((tid << 8) | rid) << 16) | cmd;
status = (ps->MFC_CMDStatus) & 0x1;
} while (status);
printf("DMA done\n");
}
In the above code, after the call to spe_ps_area_get, accessing any element of the ps area structure(which I confirmed is non-NULL) creates a hang (however program terminated thru ctrl+C).

At this point I am not sure as to why the program hangs at this statement, while probably it should have given a seg-fault, if it were to be a incorrect address space or access permission issue.

System info: Using the latest SDK based simulator using libspe2 library.

Any pointer to get out of this problem would be of immense help.

Thank you
Updated on 2008-10-21T04:36:22Z at 2008-10-21T04:36:22Z by SystemAdmin
  • jk-
    jk-
    43 Posts

    Re: Accessing ps-&gt;MFC_LSA (spe_mfc_command_area_t) creates hang.

    ‏2008-10-15T09:58:43Z  
    Hi,

    In order to access the psmap area of the SPE, the context has to be running at the time of access. Since you're not calling spe_context_run() on the context, it is never loaded to the physical SPE, and so the psmap area is never actually valid. This means that the access to the register will block indefinitely.

    Just run the context, and you'll be able to access the psmap area.

    Cheers,

    Jeremy
  • SystemAdmin
    SystemAdmin
    10114 Posts

    Re: Accessing ps-&gt;MFC_LSA (spe_mfc_command_area_t) creates hang.

    ‏2008-10-20T05:00:00Z  
    • jk-
    • ‏2008-10-15T09:58:43Z
    Hi,

    In order to access the psmap area of the SPE, the context has to be running at the time of access. Since you're not calling spe_context_run() on the context, it is never loaded to the physical SPE, and so the psmap area is never actually valid. This means that the access to the register will block indefinitely.

    Just run the context, and you'll be able to access the psmap area.

    Cheers,

    Jeremy
    Hi Jeremy,

    Thanks for that info. Unfortunately that call to spe_context_run() creates segmentation fault as (probably) there is no spe_context_load() call done to that spe. Since I am not interested in doing anything on the SPE, except use the MFC on it for DMA I am not doing any context load to that spe.

    Actually I wanted to avoid the overhead of these spe set up calls, as they server no purpose for the activity I am trying out. But looks like standing from application I have to bear them (at least a one time cost) before I can start using the MFCs meaningfully. Will try to see if I can achieve this from kernel as a module.

    Thank you.
  • gcst
    gcst
    171 Posts

    Re: Accessing ps-&gt;MFC_LSA (spe_mfc_command_area_t) creates hang.

    ‏2008-10-20T07:04:54Z  
    Hi Jeremy,

    Thanks for that info. Unfortunately that call to spe_context_run() creates segmentation fault as (probably) there is no spe_context_load() call done to that spe. Since I am not interested in doing anything on the SPE, except use the MFC on it for DMA I am not doing any context load to that spe.

    Actually I wanted to avoid the overhead of these spe set up calls, as they server no purpose for the activity I am trying out. But looks like standing from application I have to bear them (at least a one time cost) before I can start using the MFCs meaningfully. Will try to see if I can achieve this from kernel as a module.

    Thank you.
    " .. except use the MFC on it for DMA .. " can you elaborate a bit on the scenario?
  • SystemAdmin
    SystemAdmin
    10114 Posts

    Re: Accessing ps-&gt;MFC_LSA (spe_mfc_command_area_t) creates hang.

    ‏2008-10-21T04:36:22Z  
    • gcst
    • ‏2008-10-20T07:04:54Z
    " .. except use the MFC on it for DMA .. " can you elaborate a bit on the scenario?
    I just want to use the LS of that SPE as a scratchpad/temp buffer and do not want that SPE to act on it. Hence I do not want to invoke the SPE, but use its two resources MFC and LS.