All of lore.kernel.org
 help / color / mirror / Atom feed
* Problems mapping OCM memory from 460EX to user space
@ 2010-07-07 19:48 ayman
  2010-07-11  4:14 ` Ayman El-Khashab
  0 siblings, 1 reply; 2+ messages in thread
From: ayman @ 2010-07-07 19:48 UTC (permalink / raw)
  To: linuxppc-dev

I've got an issue with the new rev B 460EX processors that I am trying to isolate.
(Rev A worked fine).  In order to do that, I am trying to modify my driver to 
map the OCM (on chip memory) from the 460EX to user space so that the rest of the
application and codebase don't really know the difference.

My driver implements the mmap and this works fine when I point it to areas of 
memory that have been setup with kmalloc.  My sequence is basically kmalloc, 
adjust for page boundaries, and then remap_pfn_range.  For regular DRAM this 
works fine.

Now I want to modfiy it to use OCM.  I've modified the code to use ioremap so 
that the driver has access to the memory. This seems to work.  But the kernel 
gives a register dump when I call 

#define PLB_OCM_BASE_ADDR        0x400040000ull
...

static int mapper_mmap(struct file *fip, struct vm_area_struct *vma)
{
  int rc;
  
  /* 
   * make sure to allocate the proper number of pages when using
   * mmap.  We check it for correctness here.
   */
  
  unsigned long len = vma->vm_end - vma->vm_start;

  /* if user tries to map bigger space than we have, error */
 if (PAGE_COUNT * PAGE_SIZE < len) 
    return -EIO;

 rc = io_remap_pfn_range(vma, PLB_OCM_BASE_ADDR>>PAGE_SHIFT, vma->vm_start, len, vma->vm_page_prot);

#if 0
  /* map the physical area into one buffer */
  rc = remap_pfn_range(vma, vma->vm_start, 
		       virt_to_phys( (void*)km.pal)>>PAGE_SHIFT,
		       len,
		       vma->vm_page_prot);
#endif

  MDEBUG("Mapped %ld bytes at virt address 0x%lx to mapper file descriptor...\n", len, vma->vm_start);

  /* return an error to the caller if remap fails */
  return (rc < 0 ? rc : 0);

}

The "#if 0" code is the working code for using DRAM.  MDEBUG is just a printk.

I am fairly certain the physical address is correct, I've verified that the
TLB entries in u-boot look ok.  Any tips on how to make this work?

Thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Problems mapping OCM memory from 460EX to user space
  2010-07-07 19:48 Problems mapping OCM memory from 460EX to user space ayman
@ 2010-07-11  4:14 ` Ayman El-Khashab
  0 siblings, 0 replies; 2+ messages in thread
From: Ayman El-Khashab @ 2010-07-11  4:14 UTC (permalink / raw)
  To: linuxppc-dev

On 7/7/2010 2:48 PM, ayman@austin.rr.com wrote:
>   rc = io_remap_pfn_range(vma, PLB_OCM_BASE_ADDR>>PAGE_SHIFT, vma->vm_start, len, vma->vm_page_prot);
>
> I am fairly certain the physical address is correct, I've verified that the
> TLB entries in u-boot look ok.  Any tips on how to make this work?
>
>    

I found / fixed the issue.  The first problem is that start and offset 
are swapped in the io_remap_pfn_range invocation.  The 2nd was that
there were some TLB changes that were needed to map the OCM.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-07-11  4:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-07 19:48 Problems mapping OCM memory from 460EX to user space ayman
2010-07-11  4:14 ` Ayman El-Khashab

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.