linux-mips
[Top] [All Lists]

Re: [PATCH 3/3] MIPS: handle write_combine in pci_mmap_page_range

To: yanh <yanh@lemote.com>
Subject: Re: [PATCH 3/3] MIPS: handle write_combine in pci_mmap_page_range
From: Zhang Le <r0bertz@gentoo.org>
Date: Fri, 8 May 2009 18:18:48 +0800
Cc: linux-mips@linux-mips.org
In-reply-to: <1241772887.9177.139.camel@localhost.localdomain>
Mail-followup-to: yanh <yanh@lemote.com>, linux-mips@linux-mips.org
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <cover.1241764064.git.r0bertz@gentoo.org> <a1356a5b181a188435ff569b4f7abe57cf8fd7eb.1241764065.git.r0bertz@gentoo.org> <fb705e2eb405eea04853ae53639457a295a7dd90.1241764065.git.r0bertz@gentoo.org> <a892c7470d85f9563cc74c766fb4dd7f2fa0b801.1241764065.git.r0bertz@gentoo.org> <1241772887.9177.139.camel@localhost.localdomain>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mutt/1.5.19 (2009-01-05)
On 16:54 Fri 08 May     , yanh wrote:
> 
> 在 2009-05-08五的 14:30 +0800,Zhang Le写道:
> > Signed-off-by: Zhang Le <r0bertz@gentoo.org>
> > ---
> >  arch/mips/pci/pci.c |    8 ++++++--
> >  1 files changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> > index b0eb9e7..4ca53ef 100644
> > --- a/arch/mips/pci/pci.c
> > +++ b/arch/mips/pci/pci.c
> > @@ -346,10 +346,14 @@ int pci_mmap_page_range(struct pci_dev *dev, struct 
> > vm_area_struct *vma,
> >             return -EINVAL;
> >  
> >     /*
> > -    * Ignore write-combine; for now only return uncached mappings.
> > +    * For write-combine, return uncached accelerated mappings if CPU
> > +    * supports; otherwise, return uncached mappings.
> >      */
> >     prot = pgprot_val(vma->vm_page_prot);
> > -   prot = (prot & ~_CACHE_MASK) | _CACHE_UNCACHED;
> > +   if (write_combine && cpu_has_uncached_accelerated)
> > +           prot = (prot & ~_CACHE_MASK) | _CACHE_UNCACHED_ACCELERATED;
> > +   else
> > +           prot = (prot & ~_CACHE_MASK) | _CACHE_UNCACHED;
> >     vma->vm_page_prot = __pgprot(prot);
> This should be definietely wrong for MMIOs.
> uncache accelleration should only be enabled for addresses which have no
> side effect when doing write combine such as video memory.

Actually, currently write_combine is true only for prefetchable pci memory:
http://lxr.linux.no/linux+v2.6.29/drivers/pci/pci-sysfs.c#L711

And currently on fuloong 2f box, there is only one prefetchable pci memory
region, which just belongs to video card:

zhangle@2f /sys/devices/pci0000:00 (n32) $ find -name "*wc" -exec ls -l {} \;
-rw------- 1 root root 256M 2009-05-08 03:25 ./0000:00:08.0/resource0_wc

So, are we talking about the same thing? 

Also, I have observed that this region is larger than the actual video ram size
32M. However, libpciaccess only mapped 32M into X's address space:

zhangle@2f ~ (n32) $ sudo cat /proc/$(pidof X)/maps | grep wc$
2b354000-2d354000 rw-s 50000000 00:00 1882 
/sys/devices/pci0000:00/0000:00:08.0/resource0_wc

So, I guess this should be just ok, right?

Any other risks?

> >  
> >     return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
> 

-- 
Zhang, Le
Gentoo/Loongson Developer
http://zhangle.is-a-geek.org
0260 C902 B8F8 6506 6586 2B90 BC51 C808 1E4E 2973

Attachment: pgpwA9ozDA95o.pgp
Description: PGP signature

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