Skip to contentSkip to conversation

Mapping unchached memory with UDD

DISCUSSION Wolfgang Grandegger 2 participants 5 messages Mar 14, 2019 – Mar 16, 2019

lore
Share & tools
lore
#0 lore raw

Hello,

I'm writing a little UDD driver to handling interrupts and shared memory to communicate with a co-processor. Is it possible to setup and map a "mem_region" for *uncahced* memory. Will it be automatically uncached if it's of type UDD_MEM_PHY?

TIA,

Wolfgang.

#1 lore raw

Hi Wolfgang,

Quoted 7 lines · Wolfgang Grandegger via Xenomai

Hello,

I'm writing a little UDD driver to handling interrupts and shared memory to communicate with a co-processor. Is it possible to setup and map a "mem_region" for *uncahced* memory. Will it be automatically uncached if it's of type UDD_MEM_PHY?

Yep. Such requests is routed to RTDM's iomem mapping helper, which does:

static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa)

{
	pgprot_t prot = PAGE_SHARED;
	unsigned long len;

	len = vma->vm_end - vma->vm_start;
	...
	vma->vm_page_prot = pgprot_noncached(prot);

	return remap_pfn_range(vma, vma->vm_start, pa >> PAGE_SHIFT,
			       len, vma->vm_page_prot);
}
Signature · 1 line
Philippe.
#2 lore raw

Hello Philippe,

Am 14.03.19 um 15:32 schrieb Philippe Gerum:

Quoted 15 lines

Hi Wolfgang,

Quoted 7 lines · Wolfgang Grandegger via Xenomai

Hello,

I'm writing a little UDD driver to handling interrupts and shared memory to communicate with a co-processor. Is it possible to setup and map a "mem_region" for *uncahced* memory. Will it be automatically uncached if it's of type UDD_MEM_PHY?

Yep. Such requests is routed to RTDM's iomem mapping helper, which does:

static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa)

Quoted 11 lines
{
	pgprot_t prot = PAGE_SHARED;
	unsigned long len;

	len = vma->vm_end - vma->vm_start;
	...
	vma->vm_page_prot = pgprot_noncached(prot);

	return remap_pfn_range(vma, vma->vm_start, pa >> PAGE_SHIFT,
			       len, vma->vm_page_prot);
}

I was aware of that code! I suspected some other magic when mapping system memory with UDD_MEM_PHY. Maybe it's a barrier issue in the A9 or M4 code.

Thanks,

Wolfgang.

#3 lore raw
Quoted 26 lines · Wolfgang Grandegger

Hello Philippe,

Am 14.03.19 um 15:32 schrieb Philippe Gerum:

Quoted 23 lines

Hi Wolfgang,

Quoted 7 lines · Wolfgang Grandegger via Xenomai

Hello,

I'm writing a little UDD driver to handling interrupts and shared memory to communicate with a co-processor. Is it possible to setup and map a "mem_region" for *uncahced* memory. Will it be automatically uncached if it's of type UDD_MEM_PHY?

Yep. Such requests is routed to RTDM's iomem mapping helper, which does:

static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa)

{
	pgprot_t prot = PAGE_SHARED;
	unsigned long len;

	len = vma->vm_end - vma->vm_start;
	...
	vma->vm_page_prot = pgprot_noncached(prot);
Quoted 8 lines
Quoted 3 lines
	return remap_pfn_range(vma, vma->vm_start, pa >> PAGE_SHIFT,
			       len, vma->vm_page_prot);
}

I was aware of that code! I suspected some other magic when mapping system memory with UDD_MEM_PHY. Maybe it's a barrier issue in the A9 or M4 code.

Any DMA in between?

Signature · 1 line
Philippe.
#4 lore raw

Am 16.03.19 um 14:39 schrieb Philippe Gerum:

Quoted 31 lines · Wolfgang Grandegger
Quoted 30 lines

Hello Philippe,

Am 14.03.19 um 15:32 schrieb Philippe Gerum:

Quoted 26 lines

Hi Wolfgang,

Quoted 7 lines · Wolfgang Grandegger via Xenomai

Hello,

I'm writing a little UDD driver to handling interrupts and shared memory to communicate with a co-processor. Is it possible to setup and map a "mem_region" for *uncahced* memory. Will it be automatically uncached if it's of type UDD_MEM_PHY?

Yep. Such requests is routed to RTDM's iomem mapping helper, which does:

static int mmap_iomem_helper(struct vm_area_struct *vma, phys_addr_t pa)

{
	pgprot_t prot = PAGE_SHARED;
	unsigned long len;

	len = vma->vm_end - vma->vm_start;
	...
	vma->vm_page_prot = pgprot_noncached(prot);

	return remap_pfn_range(vma, vma->vm_start, pa >> PAGE_SHIFT,
			       len, vma->vm_page_prot);
}
Quoted 6 lines
Quoted 4 lines

I was aware of that code! I suspected some other magic when mapping system memory with UDD_MEM_PHY. Maybe it's a barrier issue in the A9 or M4 code.

Any DMA in between?

No, just programmed I/O.

Wolfgang.