Commit cd391e20 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: ctxfi - Remove PAGE_SIZE limitation

Remove the limitation of PAGE_SIZE to be 4k by defining the own
page size and macros for 4k.  8kb page size could be natively supported,
but it's disabled right now for simplicity.

Also, clean up using upper_32_bits() macro.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent d2b9b96c
...@@ -277,7 +277,6 @@ config SND_CS5535AUDIO ...@@ -277,7 +277,6 @@ config SND_CS5535AUDIO
config SND_CTXFI config SND_CTXFI
tristate "Creative Sound Blaster X-Fi" tristate "Creative Sound Blaster X-Fi"
depends on X86
select SND_PCM select SND_PCM
help help
If you want to use soundcards based on Creative Sound Blastr X-Fi If you want to use soundcards based on Creative Sound Blastr X-Fi
......
...@@ -1249,18 +1249,14 @@ static int hw_trn_init(struct hw *hw, const struct trn_conf *info) ...@@ -1249,18 +1249,14 @@ static int hw_trn_init(struct hw *hw, const struct trn_conf *info)
} }
trnctl = 0x13; /* 32-bit, 4k-size page */ trnctl = 0x13; /* 32-bit, 4k-size page */
#if BITS_PER_LONG == 64 ptp_phys_low = (u32)info->vm_pgt_phys;
ptp_phys_low = info->vm_pgt_phys & ((1UL<<32)-1); ptp_phys_high = upper_32_bits(info->vm_pgt_phys);
ptp_phys_high = (info->vm_pgt_phys>>32) & ((1UL<<32)-1); if (sizeof(void *) == 8) /* 64bit address */
trnctl |= (1<<2); trnctl |= (1 << 2);
#elif BITS_PER_LONG == 32 #if 0 /* Only 4k h/w pages for simplicitiy */
ptp_phys_low = info->vm_pgt_phys & (~0UL);
ptp_phys_high = 0;
#else
# error "Unknown BITS_PER_LONG!"
#endif
#if PAGE_SIZE == 8192 #if PAGE_SIZE == 8192
trnctl |= (1<<5); trnctl |= (1<<5);
#endif
#endif #endif
hw_write_20kx(hw, PTPALX, ptp_phys_low); hw_write_20kx(hw, PTPALX, ptp_phys_low);
hw_write_20kx(hw, PTPAHX, ptp_phys_high); hw_write_20kx(hw, PTPAHX, ptp_phys_high);
......
...@@ -1203,19 +1203,10 @@ static int hw_trn_init(struct hw *hw, const struct trn_conf *info) ...@@ -1203,19 +1203,10 @@ static int hw_trn_init(struct hw *hw, const struct trn_conf *info)
} }
vmctl = 0x80000C0F; /* 32-bit, 4k-size page */ vmctl = 0x80000C0F; /* 32-bit, 4k-size page */
#if BITS_PER_LONG == 64 ptp_phys_low = (u32)info->vm_pgt_phys;
ptp_phys_low = info->vm_pgt_phys & ((1UL<<32)-1); ptp_phys_high = upper_32_bits(info->vm_pgt_phys);
ptp_phys_high = (info->vm_pgt_phys>>32) & ((1UL<<32)-1); if (sizeof(void *) == 8) /* 64bit address */
vmctl |= (3<<8); vmctl |= (3 << 8);
#elif BITS_PER_LONG == 32
ptp_phys_low = info->vm_pgt_phys & (~0UL);
ptp_phys_high = 0;
#else
# error "Unknown BITS_PER_LONG!"
#endif
#if PAGE_SIZE == 8192
# error "Don't support 8k-page!"
#endif
/* Write page table physical address to all PTPAL registers */ /* Write page table physical address to all PTPAL registers */
for (i = 0; i < 64; i++) { for (i = 0; i < 64; i++) {
hw_write_20kx(hw, VMEM_PTPAL+(16*i), ptp_phys_low); hw_write_20kx(hw, VMEM_PTPAL+(16*i), ptp_phys_low);
......
...@@ -18,12 +18,11 @@ ...@@ -18,12 +18,11 @@
#include "ctvmem.h" #include "ctvmem.h"
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <asm/page.h> /* for PAGE_SIZE macro definition */
#include <linux/io.h> #include <linux/io.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#define CT_PTES_PER_PAGE (PAGE_SIZE / sizeof(void *)) #define CT_PTES_PER_PAGE (CT_PAGE_SIZE / sizeof(void *))
#define CT_ADDRS_PER_PAGE (CT_PTES_PER_PAGE * PAGE_SIZE) #define CT_ADDRS_PER_PAGE (CT_PTES_PER_PAGE * CT_PAGE_SIZE)
/* * /* *
* Find or create vm block based on requested @size. * Find or create vm block based on requested @size.
...@@ -138,24 +137,24 @@ ct_vm_map(struct ct_vm *vm, void *host_addr, int size) ...@@ -138,24 +137,24 @@ ct_vm_map(struct ct_vm *vm, void *host_addr, int size)
return NULL; return NULL;
} }
start_phys = (virt_to_phys(host_addr) & PAGE_MASK); start_phys = (virt_to_phys(host_addr) & CT_PAGE_MASK);
pages = (PAGE_ALIGN(virt_to_phys(host_addr) + size) pages = (CT_PAGE_ALIGN(virt_to_phys(host_addr) + size)
- start_phys) >> PAGE_SHIFT; - start_phys) >> CT_PAGE_SHIFT;
ptp = vm->ptp[0]; ptp = vm->ptp[0];
block = get_vm_block(vm, (pages << PAGE_SHIFT)); block = get_vm_block(vm, (pages << CT_PAGE_SHIFT));
if (block == NULL) { if (block == NULL) {
printk(KERN_ERR "ctxfi: No virtual memory block that is big " printk(KERN_ERR "ctxfi: No virtual memory block that is big "
"enough to allocate!\n"); "enough to allocate!\n");
return NULL; return NULL;
} }
pte_start = (block->addr >> PAGE_SHIFT); pte_start = (block->addr >> CT_PAGE_SHIFT);
for (i = 0; i < pages; i++) for (i = 0; i < pages; i++)
ptp[pte_start+i] = start_phys + (i << PAGE_SHIFT); ptp[pte_start+i] = start_phys + (i << CT_PAGE_SHIFT);
block->addr += (virt_to_phys(host_addr) & (~PAGE_MASK)); block->addr += (virt_to_phys(host_addr) & (~CT_PAGE_MASK));
block->size = size; block->size = size;
return block; return block;
...@@ -164,9 +163,9 @@ ct_vm_map(struct ct_vm *vm, void *host_addr, int size) ...@@ -164,9 +163,9 @@ ct_vm_map(struct ct_vm *vm, void *host_addr, int size)
static void ct_vm_unmap(struct ct_vm *vm, struct ct_vm_block *block) static void ct_vm_unmap(struct ct_vm *vm, struct ct_vm_block *block)
{ {
/* do unmapping */ /* do unmapping */
block->size = ((block->addr + block->size + PAGE_SIZE - 1) block->size = ((block->addr + block->size + CT_PAGE_SIZE - 1)
& PAGE_MASK) - (block->addr & PAGE_MASK); & CT_PAGE_MASK) - (block->addr & CT_PAGE_MASK);
block->addr &= PAGE_MASK; block->addr &= CT_PAGE_MASK;
put_vm_block(vm, block); put_vm_block(vm, block);
} }
......
...@@ -23,6 +23,14 @@ ...@@ -23,6 +23,14 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/list.h> #include <linux/list.h>
/* The chip can handle the page table of 4k pages
* (emu20k1 can handle even 8k pages, but we don't use it right now)
*/
#define CT_PAGE_SIZE 4096
#define CT_PAGE_SHIFT 12
#define CT_PAGE_MASK (~(PAGE_SIZE - 1))
#define CT_PAGE_ALIGN(addr) ALIGN(addr, CT_PAGE_SIZE)
struct ct_vm_block { struct ct_vm_block {
unsigned int addr; /* starting logical addr of this block */ unsigned int addr; /* starting logical addr of this block */
unsigned int size; /* size of this device virtual mem block */ unsigned int size; /* size of this device virtual mem block */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment