Skip to contentSkip to conversation

PowerPC equivalent to dma_mmap_writecombine()?

DISCUSSION Timur Tabi 3 participants 5 messages Jul 5, 2007 – Jul 6, 2007

lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

I'm porting a driver from ARM to PowerPC, and I came across this function:

static int at91_pcm_mmap(struct snd_pcm_substream *substream,
struct vm_area_struct *vma)

{
	struct snd_pcm_runtime *runtime = substream->runtime;

	return dma_mmap_writecombine(substream->pcm->card->dev, vma,
				     runtime->dma_area,
				     runtime->dma_addr,
				     runtime->dma_bytes);
}

There are no dma_mmap_x() functions in arch/powerpc. Can someone tell me what the powerpc equivalent to dma_mmap_writecombine() is?

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
#1 lore raw

T24gVGh1cnNkYXkgMDUgSnVseSAyMDA3LCBUaW11ciBUYWJpIHdyb3RlOgo+IHN0YXRpYyBpbnQg YXQ5MV9wY21fbW1hcChzdHJ1Y3Qgc25kX3BjbV9zdWJzdHJlYW0gKnN1YnN0cmVhbSwKPiCgoKCg oKCgoHN0cnVjdCB2bV9hcmVhX3N0cnVjdCAqdm1hKQo+IHsKPiCgoKCgoKCgoHN0cnVjdCBzbmRf cGNtX3J1bnRpbWUgKnJ1bnRpbWUgPSBzdWJzdHJlYW0tPnJ1bnRpbWU7Cj4gCj4goKCgoKCgoKBy ZXR1cm4gZG1hX21tYXBfd3JpdGVjb21iaW5lKHN1YnN0cmVhbS0+cGNtLT5jYXJkLT5kZXYsIHZt YSwKPiCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoCCgIKAgcnVudGltZS0+ZG1hX2Fy ZWEsCj4goKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKAgoCCgIHJ1bnRpbWUtPmRtYV9h ZGRyLAo+IKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgIKAgoCBydW50aW1lLT5kbWFf Ynl0ZXMpOwo+IH0KPiAKPiBUaGVyZSBhcmUgbm8gZG1hX21tYXBfeCgpIGZ1bmN0aW9ucyBpbiBh cmNoL3Bvd2VycGMuIKBDYW4gc29tZW9uZSB0ZWxsIG1lIHdoYXQgdGhlIHBvd2VycGMgCj4gZXF1 aXZhbGVudCB0byBkbWFfbW1hcF93cml0ZWNvbWJpbmUoKSBpcz8KCk5vdCBzdXJlIGV4YWN0bHkg d2hhdCBhcm0gZG9lcyBoZXJlLCBidXQgaXQgc291bmRzIGxpa2UgeW91IHdhbnQKdG8gY2FsbCBy ZW1hcF9wZm5fcmFuZ2Ugd2l0aCB0aGUgX1BBR0VfTk9fQ0FDSEUgYml0IHNldCBpbiB0aGUKcHJv dGVjdGlvbiBmbGFncywgYW5kIF9QQUdFX0dVQVJERUQgbm90IHNldC4KCglBcm5kIDw+PAo=

#2 lore raw
Quoted 6 lines
Quoted 2 lines

There are no dma_mmap_x() functions in arch/powerpc. Can someone tell me what the powerpc equivalent to dma_mmap_writecombine() is?

Not sure exactly what arm does here, but it sounds like you want to call remap_pfn_range with the _PAGE_NO_CACHE bit set in the protection flags, and _PAGE_GUARDED not set.

Either that, or just map it as normal cache-coherent DMA memory.

Segher

author
#3 lore raw
In reply to Arnd Bergmann
Quoted 3 lines · Arnd Bergmann

Not sure exactly what arm does here, but it sounds like you want to call remap_pfn_range with the _PAGE_NO_CACHE bit set in the protection flags, and _PAGE_GUARDED not set.

I always have a hard time with these mapping functions. Is this right?

vma->vm_page_prot = __pgprot((pgprot_val(vma->vm_page_prot) | _PAGE_NO_CACHE) & ~_PAGE_GUARDED));

ret = remap_pfn_range(vma, vma->vm_start, runtime->dma_addr, runtime->dma_bytes, vma->vm_page_prot);

Alternatively, could I use function snd_pcm_lib_mmap_iomem() (sound/core/pcm_native.c)? It looks like it does the right thing, although it doesn't unset the guarded bit. If that's wrong, I can submit a patch to unset that bit on PowerPC, but like I said, I can never quite get my head around this mapping stuff.

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale
#4 lore raw
Quoted 9 lines · Timur Tabi

Arnd Bergmann wrote:
=20

Quoted 3 lines

Not sure exactly what arm does here, but it sounds like you want to call remap_pfn_range with the _PAGE_NO_CACHE bit set in the protection flags, and _PAGE_GUARDED not set.

=20
I always have a hard time with these mapping functions. =A0Is this right? =20
vma->vm_page_prot =3D __pgprot((pgprot_val(vma->vm_page_prot) | _PAGE_NO_=

CACHE) &=20

Quoted 3 lines

~_PAGE_GUARDED));
=20
ret =3D remap_pfn_range(vma, vma->vm_start, runtime->dma_addr, runtime->d=

ma_bytes,=20

Quoted 3 lines

vma->vm_page_prot);
=20
Alternatively, could I use function snd_pcm_lib_mmap_iomem() (sound/core/=

pcm_native.c)?=20

Quoted 1 line

It looks like it does the right thing, although it doesn't unset the guar=

ded bit. =A0If=20

Quoted 1 line

that's wrong, I can submit a patch to unset that bit on PowerPC, but like=

I said, I can=20

Quoted 1 line

never quite get my head around this mapping stuff.

The guarded bit is disabled by default, so you don't need t remove it, so the function you quoted should be alright for this purpose. Not sure if you need the ioremap in there though.

	Arnd <><