alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: "Dajie Tan" <jiankemeng@gmail.com>
To: Songmao Tian <tiansm@lemote.com>
Cc: linux-mips@linux-mips.org, alsa-devel@alsa-project.org,
	Ralf <ralf@linux-mips.org>, Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	Takashi Iwai <tiwai@suse.de>,
	greg@kroah.com
Subject: Re: ALSA on MIPS platform
Date: Tue, 7 Aug 2007 10:18:04 +0400	[thread overview]
Message-ID: <5861a7880708062317t21970c81w3f16580858bf50af@mail.gmail.com> (raw)
In-Reply-To: <5861a7880708062253x7133659cm1ff17f451e4f82f8@mail.gmail.com>

Sorry, that aim at 2.6.18.

In the latest kernel:

--- a/include/asm-mips/io.h     2007-08-07 10:18:03.000000000 +0800
+++ b/include/asm-mips/io.h     2007-08-07 10:18:56.000000000 +0800
@@ -116,7 +116,7 @@
  */
 static inline unsigned long virt_to_phys(volatile const void *address)
 {
-       return (unsigned long)address - PAGE_OFFSET + PHYS_OFFSET;
+       return ((unsigned long)address & 0x1fffffff) + PHYS_OFFSET;
 }

I think virt_to_phys or __pa should accept kseg1 address.

Tan

2007/8/7, Dajie Tan <jiankemeng@gmail.com>:
> I think this problem can be solved by revising the __pa macro like this:
>
> --- a/include/asm-mips/page.h      2007-08-07 09:45:00.000000000 +0800
> +++ b/include/asm-mips/page.h     2007-08-07 09:46:59.000000000 +0800
> @@ -150,7 +150,7 @@
>  })
>  #else
>  #define __pa(x)
>          \
> -    ((unsigned long)(x) - PAGE_OFFSET + PHYS_OFFSET)
> +    (((unsigned long)(x) & 0x1fffffff) + PHYS_OFFSET)
>  #endif
>
> So, the virt_to_page can accept all cached or uncached address.
>
>
> Tan
>
> 2007/8/3, Songmao Tian <tiansm@lemote.com>:
> > Atsushi Nemoto wrote:
> > > On Wed, 01 Aug 2007 15:56:48 +0800, Songmao Tian <tiansm@lemote.com> wrote:
> > >
> > >>     The problem is clear:
> > >> 1. dma_alloc_noncoherent() return a non-cached address, and
> > >> virt_to_page() need a cached logical addr (Have I named it right?)
> > >> 2. mmaped dam buffer should be non-cached.
> > >>
> > >> We have a ugly patch, but we want to solve the problem cleanly, so can
> > >> anyone show me the way?
> > >>
> > >
> > > virt_to_page() is used in many place in mm so making it robust might
> > > affect performance.  IMHO virt_to_page() seems too low-level as DMA
> > > API.
> > >
> > > If something like dma_virt_to_page(dev, cpu_addr) which can take a cpu
> > > address returned by dma_xxx APIs was defined, MIPS can implement it
> > > appropriately.
> > >
> > > And then pgprot_noncached issues still exist...
> > >
> > > ---
> > > Atsushi Nemoto
> > >
> > >
> > >
> > >
> >
> > I agree, and I am investigating to implement a dma_map_coherent, but It
> > seems dma_map_coherent doesn't solve all the problem and will change a
> > lot of code:(
> >
> >
> > dma_virt_to_page can be something like this.
> >
> > diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
> > index b92dd8c..d2ead8a 100644
> > --- a/include/asm-mips/page.h
> > +++ b/include/asm-mips/page.h
> > @@ -181,6 +181,8 @@ typedef struct { unsigned long pgprot; } pgprot_t;
> >  #define virt_to_page(kaddr)    pfn_to_page(PFN_DOWN(virt_to_phys(kaddr)))
> >  #define virt_addr_valid(kaddr)    pfn_valid(PFN_DOWN(virt_to_phys(kaddr)))
> >
> > +#define dma_virt_to_page(dma_addr)
> > pfn_to_page(PFN_DOWN(virt_to_phys(CAC_ADDR(kaddr))))
> > +
> >  #define VM_DATA_DEFAULT_FLAGS    (VM_READ | VM_WRITE | VM_EXEC | \
> >                   VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
> >
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index 655094d..5e694dd 100644
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@ -39,6 +39,10 @@ extern int sysctl_legacy_va_layout;
> >  #include <asm/pgtable.h>
> >  #include <asm/processor.h>
> >
> > +#ifndef dma_virt_to_page
> > +#define dma_virt_to_page virt_to_page
> > +#endif
> > +
> >  #define nth_page(page,n) pfn_to_page(page_to_pfn((page)) + (n))
> >
> >  /*
> > diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c
> > index cefd228..8b29bfd 100644
> > --- a/sound/core/sgbuf.c
> > +++ b/sound/core/sgbuf.c
> > @@ -91,7 +91,7 @@ void *snd_malloc_sgbuf_pages(struct device *device,
> >          }
> >          sgbuf->table[i].buf = tmpb.area;
> >          sgbuf->table[i].addr = tmpb.addr;
> > -        sgbuf->page_table[i] = virt_to_page(tmpb.area);
> > +        sgbuf->page_table[i] = dma_virt_to_page(tmpb.area);
> >          sgbuf->pages++;
> >      }
> >
> >
>


-- 
为天地立心
为生民立命
为往圣继绝学
为万世开太平

  reply	other threads:[~2007-08-07  6:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-01  7:56 ALSA on MIPS platform Songmao Tian
2007-08-02 14:56 ` Atsushi Nemoto
2007-08-03 13:50   ` Songmao Tian
2007-08-03 13:59     ` Takashi Iwai
2007-08-03 15:57       ` Songmao Tian
2007-08-06 12:17         ` Takashi Iwai
2007-08-07  5:53     ` Dajie Tan
2007-08-07  6:18       ` Dajie Tan [this message]
2007-08-07 14:01         ` Atsushi Nemoto
2007-08-07 17:54           ` Ralf Baechle
2007-08-07 18:41             ` Takashi Iwai
2007-08-08 11:58               ` Ralf Baechle
2007-08-08 12:40                 ` Maciej W. Rozycki
2007-08-08 12:57                 ` Takashi Iwai
2007-08-09  1:24             ` Songmao Tian
2007-08-08  0:40           ` Songmao Tian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5861a7880708062317t21970c81w3f16580858bf50af@mail.gmail.com \
    --to=jiankemeng@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=anemo@mba.ocn.ne.jp \
    --cc=greg@kroah.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=tiansm@lemote.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).