Implement sf_buf using direct map (XKPHYS) in MIPS n64.

- Provide trivial implementation of sf_buf_alloc(), sf_buf_free(),
  sf_buf_kva() and sf_buf_page() using direct map for n64.
- uio_machdep.c - use macros so that the direct map will be used in
  case of n64.

Reviewed by:	imp (earlier version)
Obtained from:	jmallett (user/jmallett/octeon)
This commit is contained in:
Jayachandran C. 2011-01-27 14:49:22 +00:00
parent 7b87c35eba
commit 21835e695a
3 changed files with 40 additions and 3 deletions

View File

@ -29,8 +29,35 @@
#ifndef _MACHINE_SF_BUF_H_
#define _MACHINE_SF_BUF_H_
#ifdef __mips_n64
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/vm_page.h>
#else
#include <sys/queue.h>
#endif
#ifdef __mips_n64
/* In 64 bit the whole memory is directly mapped */
struct sf_buf;
static __inline vm_offset_t
sf_buf_kva(struct sf_buf *sf)
{
vm_page_t m;
m = (vm_page_t)sf;
return (MIPS_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m)));
}
static __inline struct vm_page *
sf_buf_page(struct sf_buf *sf)
{
return ((vm_page_t)sf);
}
#else /* ! __mips_n64 */
struct vm_page;
struct sf_buf {
@ -52,5 +79,6 @@ sf_buf_page(struct sf_buf *sf)
return (sf->m);
}
#endif /* __mips_n64 */
#endif /* !_MACHINE_SF_BUF_H_ */

View File

@ -92,9 +92,9 @@ uiomove_fromphys(vm_page_t ma[], vm_offset_t offset, int n, struct uio *uio)
cnt = ulmin(cnt, PAGE_SIZE - page_offset);
m = ma[offset >> PAGE_SHIFT];
pa = VM_PAGE_TO_PHYS(m);
if (pa < MIPS_KSEG0_LARGEST_PHYS) {
if (MIPS_DIRECT_MAPPABLE(pa)) {
sf = NULL;
cp = (char *)MIPS_PHYS_TO_KSEG0(pa) + page_offset;
cp = (char *)MIPS_PHYS_TO_DIRECT(pa) + page_offset;
/*
* flush all mappings to this page, KSEG0 address first
* in order to get it overwritten by correct data

View File

@ -82,6 +82,7 @@ __FBSDID("$FreeBSD$");
#define NSFBUFS (512 + maxusers * 16)
#endif
#ifndef __mips_n64
static void sf_buf_init(void *arg);
SYSINIT(sock_sf, SI_SUB_MBUF, SI_ORDER_ANY, sf_buf_init, NULL);
@ -95,6 +96,7 @@ static struct {
} sf_freelist;
static u_int sf_buf_alloc_want;
#endif
/*
* Finish a fork operation, with process p2 nearly set up.
@ -458,6 +460,7 @@ kvtop(void *addr)
/*
* Allocate a pool of sf_bufs (sendfile(2) or "super-fast" if you prefer. :-))
*/
#ifndef __mips_n64
static void
sf_buf_init(void *arg)
{
@ -479,6 +482,7 @@ sf_buf_init(void *arg)
}
sf_buf_alloc_want = 0;
}
#endif
/*
* Get an sf_buf from the freelist. Will block if none are available.
@ -486,6 +490,7 @@ sf_buf_init(void *arg)
struct sf_buf *
sf_buf_alloc(struct vm_page *m, int flags)
{
#ifndef __mips_n64
struct sf_buf *sf;
int error;
@ -514,6 +519,9 @@ sf_buf_alloc(struct vm_page *m, int flags)
}
mtx_unlock(&sf_freelist.sf_lock);
return (sf);
#else
return ((struct sf_buf *)m);
#endif
}
/*
@ -522,7 +530,7 @@ sf_buf_alloc(struct vm_page *m, int flags)
void
sf_buf_free(struct sf_buf *sf)
{
#ifndef __mips_n64
pmap_qremove(sf->kva, 1);
mtx_lock(&sf_freelist.sf_lock);
SLIST_INSERT_HEAD(&sf_freelist.sf_head, sf, free_list);
@ -530,6 +538,7 @@ sf_buf_free(struct sf_buf *sf)
if (sf_buf_alloc_want > 0)
wakeup(&sf_freelist);
mtx_unlock(&sf_freelist.sf_lock);
#endif
}
/*