Commit bfc1de0c authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6: (24 commits)
  [SPARC]: Add solaris/sunos binary support to feature removal schedule.
  [SPARC]: Merge asm-sparc{,64}/a.out.h
  [SPARC]: Merge asm-sparc{,64}/fb.h
  [SPARC]: Merge asm-sparc{,64}/errno.h
  [SPARC]: Merge asm-sparc{,64}/emergency-restart.h
  [SPARC]: Merge asm-sparc{,64}/div64.h
  [SPARC]: Merge asm-sparc{,64}/device.h
  [SPARC]: Merge asm-sparc{,64}/current.h
  [SPARC]: Merge asm-sparc{,64}/cputime.h
  [SPARC]: Merge asm-sparc{,64}/cache.h
  [SPARC]: Merge asm-sparc{,64}/byteorder.h
  [SPARC]: Merge asm-sparc{,64}/bugs.h
  [SPARC]: Merge asm-sparc{,64}/bug.h
  [SPARC]: Kill BSD errno translation table and header files.
  [SPARC]: Merge asm-sparc{,64}/bpp.h
  [SPARC]: Merge include/asm-sparc{,64}/auxvec.h
  [SPARC]: Merge include/asm-sparc{,64}/of_device.h
  [SPARC]: Merge include/asm-sparc{,64}/prom.h
  [SPARC]: Remove of_platform_device_create
  [SPARC64]: Add kretprobe support.
  ...
parents 1712a699 e88bb415
......@@ -304,3 +304,14 @@ Why: The support code for the old firmware hurts code readability/maintainabilit
and slightly hurts runtime performance. Bugfixes for the old firmware
are not provided by Broadcom anymore.
Who: Michael Buesch <mb@bu3sch.de>
---------------------------
What: Solaris/SunOS syscall and binary support on Sparc
When: 2.6.26
Why: Largely unmaintained and almost entirely unused. File system
layering used to divert library and dynamic linker searches to
/usr/gnemul is extremely buggy and unfixable. Making it work
is largely pointless as without a lot of work only the most
trivial of Solaris binaries can work with the emulation code.
Who: David S. Miller <davem@davemloft.net>
/* $Id: errtbls.c,v 1.2 1995/11/25 00:57:55 davem Exp $
* errtbls.c: Error number conversion tables between various syscall
* OS semantics.
/* errtbls.c: Error number conversion tables.
*
* Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
* Copyright (C) 1995, 2007 David S. Miller (davem@davemloft.net)
*
* Based upon preliminary work which is:
*
* Copyright (C) 1995 Adrian M. Rodriguez (adrian@remus.rutgers.edu)
*/
#include <asm/bsderrno.h> /* NetBSD (bsd4.4) errnos */
#include <asm/solerrno.h> /* Solaris errnos */
/* Here are tables which convert between Linux/SunOS error number
* values to the equivalent in other OSs. Note that since the Linux
* ones have been set up to match exactly those of SunOS, no
* translation table is needed for that OS.
/* Here is the table which converts between Linux error number values
* to the equivalent under Solaris. Note that since the Linux ones
* have been set up to match exactly those of SunOS, no translation
* table is needed for that OS.
*/
int solaris_errno[] = {
......@@ -145,132 +142,3 @@ int solaris_errno[] = {
SOL_ELIBMAX,
SOL_ELIBSCN,
};
int netbsd_errno[] = {
0,
BSD_EPERM,
BSD_ENOENT,
BSD_ESRCH,
BSD_EINTR,
BSD_EIO,
BSD_ENXIO,
BSD_E2BIG,
BSD_ENOEXEC,
BSD_EBADF,
BSD_ECHILD,
BSD_EAGAIN,
BSD_ENOMEM,
BSD_EACCES,
BSD_EFAULT,
BSD_NOTBLK,
BSD_EBUSY,
BSD_EEXIST,
BSD_EXDEV,
BSD_ENODEV,
BSD_ENOTDIR,
BSD_EISDIR,
BSD_EINVAL,
BSD_ENFILE,
BSD_EMFILE,
BSD_ENOTTY,
BSD_ETXTBSY,
BSD_EFBIG,
BSD_ENOSPC,
BSD_ESPIPE,
BSD_EROFS,
BSD_EMLINK,
BSD_EPIPE,
BSD_EDOM,
BSD_ERANGE,
BSD_EWOULDBLOCK,
BSD_EINPROGRESS,
BSD_EALREADY,
BSD_ENOTSOCK,
BSD_EDESTADDRREQ,
BSD_EMSGSIZE,
BSD_EPROTOTYPE,
BSD_ENOPROTOOPT,
BSD_EPROTONOSUPPORT,
BSD_ESOCKTNOSUPPORT,
BSD_EOPNOTSUPP,
BSD_EPFNOSUPPORT,
BSD_EAFNOSUPPORT,
BSD_EADDRINUSE,
BSD_EADDRNOTAVAIL,
BSD_ENETDOWN,
BSD_ENETUNREACH,
BSD_ENETRESET,
BSD_ECONNABORTED,
BSD_ECONNRESET,
BSD_ENOBUFS,
BSD_EISCONN,
BSD_ENOTONN,
BSD_ESHUTDOWN,
BSD_ETOOMANYREFS,
BSD_ETIMEDOUT,
BSD_ECONNREFUSED,
BSD_ELOOP,
BSD_ENAMETOOLONG,
BSD_EHOSTDOWN,
BSD_EHOSTUNREACH,
BSD_ENOTEMPTY,
BSD_EPROCLIM,
BSD_EUSERS,
BSD_EDQUOT,
BSD_ESTALE,
BSD_EREMOTE,
BSD_ENOSTR,
BSD_ETIME,
BSD_ENOSR,
BSD_ENOMSG,
BSD_EBADMSG,
BSD_IDRM,
BSD_EDEADLK,
BSD_ENOLCK,
BSD_ENONET,
BSD_ERREMOTE,
BSD_ENOLINK,
BSD_EADV,
BSD_ESRMNT,
BSD_ECOMM,
BSD_EPROTO,
BSD_EMULTIHOP,
BSD_EINVAL, /* EDOTDOT XXX??? */
BSD_REMCHG,
BSD_NOSYS,
BSD_STRPIPE,
BSD_EOVERFLOW,
BSD_EBADFD,
BSD_ECHRNG,
BSD_EL2NSYNC,
BSD_EL3HLT,
BSD_EL3RST,
BSD_NRNG,
BSD_EUNATCH,
BSD_ENOCSI,
BSD_EL2HLT,
BSD_EBADE,
BSD_EBADR,
BSD_EXFULL,
BSD_ENOANO,
BSD_EBADRQC,
BSD_EBADSLT,
BSD_EDEADLOCK,
BSD_EBFONT,
BSD_ELIBEXEC,
BSD_ENODATA,
BSD_ELIBBAD,
BSD_ENOPKG,
BSD_ELIBACC,
BSD_ENOTUNIQ,
BSD_ERESTART,
BSD_EUCLEAN,
BSD_ENOTNAM,
BSD_ENAVAIL,
BSD_EISNAM,
BSD_EREMOTEIO,
BSD_EILSEQ,
BSD_ELIBMAX,
BSD_ELIBSCN,
};
......@@ -584,30 +584,3 @@ static int __init of_debug(char *str)
}
__setup("of_debug=", of_debug);
struct of_device* of_platform_device_create(struct device_node *np,
const char *bus_id,
struct device *parent,
struct bus_type *bus)
{
struct of_device *dev;
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev)
return NULL;
dev->dev.parent = parent;
dev->dev.bus = bus;
dev->dev.release = of_release_dev;
strlcpy(dev->dev.bus_id, bus_id, BUS_ID_SIZE);
if (of_device_register(dev) != 0) {
kfree(dev);
return NULL;
}
return dev;
}
EXPORT_SYMBOL(of_platform_device_create);
......@@ -89,6 +89,10 @@ SECTIONS
.data.cacheline_aligned : {
*(.data.cacheline_aligned)
}
. = ALIGN(32);
.data.read_mostly : {
*(.data.read_mostly)
}
__bss_start = .;
.sbss : {
......
......@@ -41,6 +41,10 @@ config MMU
bool
default y
config IOMMU_HELPER
bool
default y
config QUICKLIST
bool
default y
......
/* iommu.c: Generic sparc64 IOMMU support.
*
* Copyright (C) 1999, 2007 David S. Miller (davem@davemloft.net)
* Copyright (C) 1999, 2007, 2008 David S. Miller (davem@davemloft.net)
* Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com)
*/
......@@ -10,6 +10,7 @@
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/errno.h>
#include <linux/iommu-helper.h>
#ifdef CONFIG_PCI
#include <linux/pci.h>
......@@ -41,7 +42,7 @@
"i" (ASI_PHYS_BYPASS_EC_E))
/* Must be invoked under the IOMMU lock. */
static void __iommu_flushall(struct iommu *iommu)
static void iommu_flushall(struct iommu *iommu)
{
if (iommu->iommu_flushinv) {
iommu_write(iommu->iommu_flushinv, ~(u64)0);
......@@ -83,54 +84,91 @@ static inline void iopte_make_dummy(struct iommu *iommu, iopte_t *iopte)
iopte_val(*iopte) = val;
}
/* Based largely upon the ppc64 iommu allocator. */
static long arena_alloc(struct iommu *iommu, unsigned long npages)
/* Based almost entirely upon the ppc64 iommu allocator. If you use the 'handle'
* facility it must all be done in one pass while under the iommu lock.
*
* On sun4u platforms, we only flush the IOMMU once every time we've passed
* over the entire page table doing allocations. Therefore we only ever advance
* the hint and cannot backtrack it.
*/
unsigned long iommu_range_alloc(struct device *dev,
struct iommu *iommu,
unsigned long npages,
unsigned long *handle)
{
unsigned long n, end, start, limit, boundary_size;
struct iommu_arena *arena = &iommu->arena;
unsigned long n, i, start, end, limit;
int pass;
int pass = 0;
/* This allocator was derived from x86_64's bit string search */
/* Sanity check */
if (unlikely(npages == 0)) {
if (printk_ratelimit())
WARN_ON(1);
return DMA_ERROR_CODE;
}
if (handle && *handle)
start = *handle;
else
start = arena->hint;
limit = arena->limit;
start = arena->hint;
pass = 0;
again:
n = find_next_zero_bit(arena->map, limit, start);
end = n + npages;
if (unlikely(end >= limit)) {
/* The case below can happen if we have a small segment appended
* to a large, or when the previous alloc was at the very end of
* the available space. If so, go back to the beginning and flush.
*/
if (start >= limit) {
start = 0;
if (iommu->flush_all)
iommu->flush_all(iommu);
}
again:
if (dev)
boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
1 << IO_PAGE_SHIFT);
else
boundary_size = ALIGN(1UL << 32, 1 << IO_PAGE_SHIFT);
n = iommu_area_alloc(arena->map, limit, start, npages, 0,
boundary_size >> IO_PAGE_SHIFT, 0);
if (n == -1) {
if (likely(pass < 1)) {
limit = start;
/* First failure, rescan from the beginning. */
start = 0;
__iommu_flushall(iommu);
if (iommu->flush_all)
iommu->flush_all(iommu);
pass++;
goto again;
} else {
/* Scanned the whole thing, give up. */
return -1;
}
}
for (i = n; i < end; i++) {
if (test_bit(i, arena->map)) {
start = i + 1;
goto again;
/* Second failure, give up */
return DMA_ERROR_CODE;
}
}
for (i = n; i < end; i++)
__set_bit(i, arena->map);
end = n + npages;
arena->hint = end;
/* Update handle for SG allocations */
if (handle)
*handle = end;
return n;
}
static void arena_free(struct iommu_arena *arena, unsigned long base, unsigned long npages)
void iommu_range_free(struct iommu *iommu, dma_addr_t dma_addr, unsigned long npages)
{
unsigned long i;
struct iommu_arena *arena = &iommu->arena;
unsigned long entry;
for (i = base; i < (base + npages); i++)
__clear_bit(i, arena->map);
entry = (dma_addr - iommu->page_table_map_base) >> IO_PAGE_SHIFT;
iommu_area_free(arena->map, entry, npages);
}
int iommu_table_init(struct iommu *iommu, int tsbsize,
......@@ -156,6 +194,9 @@ int iommu_table_init(struct iommu *iommu, int tsbsize,
}
iommu->arena.limit = num_tsb_entries;
if (tlb_type != hypervisor)
iommu->flush_all = iommu_flushall;
/* Allocate and initialize the dummy page which we
* set inactive IO PTEs to point to.
*/
......@@ -192,22 +233,18 @@ out_free_map:
return -ENOMEM;
}
static inline iopte_t *alloc_npages(struct iommu *iommu, unsigned long npages)
static inline iopte_t *alloc_npages(struct device *dev, struct iommu *iommu,
unsigned long npages)
{
long entry;
unsigned long entry;
entry = arena_alloc(iommu, npages);
if (unlikely(entry < 0))
entry = iommu_range_alloc(dev, iommu, npages, NULL);
if (unlikely(entry == DMA_ERROR_CODE))
return NULL;
return iommu->page_table + entry;
}
static inline void free_npages(struct iommu *iommu, dma_addr_t base, unsigned long npages)
{
arena_free(&iommu->arena, base >> IO_PAGE_SHIFT, npages);
}
static int iommu_alloc_ctx(struct iommu *iommu)
{
int lowest = iommu->ctx_lowest_free;
......@@ -258,7 +295,7 @@ static void *dma_4u_alloc_coherent(struct device *dev, size_t size,
iommu = dev->archdata.iommu;
spin_lock_irqsave(&iommu->lock, flags);
iopte = alloc_npages(iommu, size >> IO_PAGE_SHIFT);
iopte = alloc_npages(dev, iommu, size >> IO_PAGE_SHIFT);
spin_unlock_irqrestore(&iommu->lock, flags);
if (unlikely(iopte == NULL)) {
......@@ -296,7 +333,7 @@ static void dma_4u_free_coherent(struct device *dev, size_t size,
spin_lock_irqsave(&iommu->lock, flags);
free_npages(iommu, dvma - iommu->page_table_map_base, npages);
iommu_range_free(iommu, dvma, npages);
spin_unlock_irqrestore(&iommu->lock, flags);
......@@ -327,7 +364,7 @@ static dma_addr_t dma_4u_map_single(struct device *dev, void *ptr, size_t sz,
npages >>= IO_PAGE_SHIFT;
spin_lock_irqsave(&iommu->lock, flags);
base = alloc_npages(iommu, npages);
base = alloc_npages(dev, iommu, npages);
ctx = 0;
if (iommu->iommu_ctxflush)
ctx = iommu_alloc_ctx(iommu);
......@@ -465,7 +502,7 @@ static void dma_4u_unmap_single(struct device *dev, dma_addr_t bus_addr,
for (i = 0; i < npages; i++)
iopte_make_dummy(iommu, base + i);
free_npages(iommu, bus_addr - iommu->page_table_map_base, npages);
iommu_range_free(iommu, bus_addr, npages);
iommu_free_ctx(iommu, ctx);
......@@ -475,124 +512,209 @@ static void dma_4u_unmap_single(struct device *dev, dma_addr_t bus_addr,
static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
int nelems, enum dma_data_direction direction)
{
unsigned long flags, ctx, i, npages, iopte_protection;
struct scatterlist *sg;
struct scatterlist *s, *outs, *segstart;
unsigned long flags, handle, prot, ctx;
dma_addr_t dma_next = 0, dma_addr;
unsigned int max_seg_size;
int outcount, incount, i;
struct strbuf *strbuf;
struct iommu *iommu;
iopte_t *base;
u32 dma_base;
/* Fast path single entry scatterlists. */
if (nelems == 1) {
sglist->dma_address =
dma_4u_map_single(dev, sg_virt(sglist),
sglist->length, direction);
if (unlikely(sglist->dma_address == DMA_ERROR_CODE))
return 0;
sglist->dma_length = sglist->length;
return 1;
}
BUG_ON(direction == DMA_NONE);
iommu = dev->archdata.iommu;
strbuf = dev->archdata.stc;
if (unlikely(direction == DMA_NONE))
goto bad_no_ctx;
npages = calc_npages(sglist, nelems);
if (nelems == 0 || !iommu)
return 0;
spin_lock_irqsave(&iommu->lock, flags);
base = alloc_npages(iommu, npages);
ctx = 0;
if (iommu->iommu_ctxflush)
ctx = iommu_alloc_ctx(iommu);
spin_unlock_irqrestore(&iommu->lock, flags);
if (base == NULL)
goto bad;
dma_base = iommu->page_table_map_base +
((base - iommu->page_table) << IO_PAGE_SHIFT);
if (strbuf->strbuf_enabled)
iopte_protection = IOPTE_STREAMING(ctx);
prot = IOPTE_STREAMING(ctx);
else
iopte_protection = IOPTE_CONSISTENT(ctx);
prot = IOPTE_CONSISTENT(ctx);
if (direction != DMA_TO_DEVICE)
iopte_protection |= IOPTE_WRITE;
for_each_sg(sglist, sg, nelems, i) {
unsigned long paddr = SG_ENT_PHYS_ADDRESS(sg);
unsigned long slen = sg->length;
unsigned long this_npages;
prot |= IOPTE_WRITE;
outs = s = segstart = &sglist[0];
outcount = 1;
incount = nelems;
handle = 0;
/* Init first segment length for backout at failure */
outs->dma_length = 0;
max_seg_size = dma_get_max_seg_size(dev);
for_each_sg(sglist, s, nelems, i) {
unsigned long paddr, npages, entry, slen;
iopte_t *base;
slen = s->length;
/* Sanity check */
if (slen == 0) {
dma_next = 0;
continue;
}
/* Allocate iommu entries for that segment */
paddr = (unsigned long) SG_ENT_PHYS_ADDRESS(s);
npages = iommu_num_pages(paddr, slen);
entry = iommu_range_alloc(dev, iommu, npages, &handle);
/* Handle failure */
if (unlikely(entry == DMA_ERROR_CODE)) {
if (printk_ratelimit())
printk(KERN_INFO "iommu_alloc failed, iommu %p paddr %lx"
" npages %lx\n", iommu, paddr, npages);
goto iommu_map_failed;
}
this_npages = iommu_num_pages(paddr, slen);
base = iommu->page_table + entry;
sg->dma_address = dma_base | (paddr & ~IO_PAGE_MASK);
sg->dma_length = slen;
/* Convert entry to a dma_addr_t */
dma_addr = iommu->page_table_map_base +
(entry << IO_PAGE_SHIFT);
dma_addr |= (s->offset & ~IO_PAGE_MASK);
/* Insert into HW table */
paddr &= IO_PAGE_MASK;
while (this_npages--) {
iopte_val(*base) = iopte_protection | paddr;
while (npages--) {
iopte_val(*base) = prot | paddr;
base++;
paddr += IO_PAGE_SIZE;
dma_base += IO_PAGE_SIZE;
}
/* If we are in an open segment, try merging */
if (segstart != s) {
/* We cannot merge if:
* - allocated dma_addr isn't contiguous to previous allocation
*/
if ((dma_addr != dma_next) ||
(outs->dma_length + s->length > max_seg_size)) {
/* Can't merge: create a new segment */
segstart = s;
outcount++;
outs = sg_next(outs);
} else {
outs->dma_length += s->length;
}
}
if (segstart == s) {
/* This is a new segment, fill entries */
outs->dma_address = dma_addr;
outs->dma_length = slen;
}
/* Calculate next page pointer for contiguous check */
dma_next = dma_addr + slen;
}
return nelems;
spin_unlock_irqrestore(&iommu->lock, flags);
if (outcount < incount) {
outs = sg_next(outs);
outs->dma_address = DMA_ERROR_CODE;
outs->dma_length = 0;
}
return outcount;
iommu_map_failed:
for_each_sg(sglist, s, nelems, i) {
if (s->dma_length != 0) {
unsigned long vaddr, npages, entry, i;
iopte_t *base;
vaddr = s->dma_address & IO_PAGE_MASK;
npages = iommu_num_pages(s->dma_address, s->dma_length);
iommu_range_free(iommu, vaddr, npages);
entry = (vaddr - iommu->page_table_map_base)
>> IO_PAGE_SHIFT;
base = iommu->page_table + entry;