linux-mips
[Top] [All Lists]

Re: [PATCH] mips: Add dma_mmap_coherent()

To: tsbogend@alpha.franken.de (Thomas Bogendoerfer)
Subject: Re: [PATCH] mips: Add dma_mmap_coherent()
From: Takashi Iwai <tiwai@suse.de>
Date: Fri, 22 Aug 2008 12:23:48 +0200
Cc: ralf@linux-mips.org, James Bottomley <James.Bottomley@HansenPartnership.com>, linux-mips@linux-mips.org, Parisc List <linux-parisc@vger.kernel.org>
In-reply-to: <20080822094131.GA6717@alpha.franken.de>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <s5hk5eezcfe.wl%tiwai@suse.de> <1219249633.3258.18.camel@localhost.localdomain> <s5hzln7vd9d.wl%tiwai@suse.de> <1219255088.3258.45.camel@localhost.localdomain> <s5hr68ivfer.wl%tiwai@suse.de> <1219326912.3265.2.camel@localhost.localdomain> <s5hhc9enyqa.wl%tiwai@suse.de> <s5hfxoynyn4.wl%tiwai@suse.de> <20080821214118.GA12516@alpha.franken.de> <s5hbpzl8tvz.wl%tiwai@suse.de> <20080822094131.GA6717@alpha.franken.de>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Wanderlust/2.12.0 (Your Wildest Dreams) SEMI/1.14.6 (Maruoka) FLIM/1.14.7 (Sanjō) APEL/10.6 Emacs/22.2 (x86_64-suse-linux-gnu) MULE/5.0 (SAKAKI)
At Fri, 22 Aug 2008 11:41:31 +0200,
Thomas Bogendoerfer wrote:
> 
> On Fri, Aug 22, 2008 at 08:07:44AM +0200, Takashi Iwai wrote:
> > I don't think that this must work for *every* platform, too, and it's
> > not expected from the driver.  The systems without uncached memory
> > access can simply return an error from  dma_mmap_coherent() call, so
> > that the driver can disable the mmap.  That'd be enough.
> 
> true, I've used snd_pcm_indirect for HAL2 driver, which works even on
> SGI IP28 machines.
> 
> > Now, how to handle these exceptions: a question comes into my mind
> > again -- how does the framebuffer handle these as well?
> 
> most framebuffers have a dedicated set of video memory and this memory is
> just mmaped uncached either via TLB/MMU (MIPS) or rules inside
> the system (PARISC uses IO space memory, which is always uncached). 
> The code which does this mmaping is in drivers/video/fbmem.c plus
> fb_pgprotect out of an include/asm header file. 

Thanks.  These are the files I already looked at, and pgprot fiddling
is already in my last patches (and apparently they not enough).

> For framebuffers without dedicated video memory the memory is mmaped
> write through or uncached. A driver, which uses this, is 
> drivers/video/gbefb.c.

So, adding a code like below to dma_mmap_coherent() for MIPS?

static inline pgprot_t pgprot_mmap(pgprot_t _prot)
{
        unsigned long prot = pgprot_val(_prot) & ~_CACHE_MASK;
#ifdef CONFIG_SGI_IP32
#ifdef CONFIG_CPU_R10000
        prot = prot | _CACHE_UNCACHED_ACCELERATED;
#else
        prot = prot | _CACHE_CACHABLE_NO_WA;
#endif
#else
        prot = prot | _CACHE_UNCACHED;
#endif
        return __pgprot(prot);
}

dma_mmap_coherent()
{
        ...
        vma->vm_page_prot = pgprot_mmap(vma->vm_page_prot);
        ...
        remap_pfn_range(...);
}


thanks,

Takashi

<Prev in Thread] Current Thread [Next in Thread>