2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2006-09-27 14:49:57 +08:00
|
|
|
* arch/sh/kernel/cpu/sh4/sq.c
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* General management API for SH-4 integrated Store Queues
|
|
|
|
*
|
2006-09-27 14:49:57 +08:00
|
|
|
* Copyright (C) 2001 - 2006 Paul Mundt
|
2005-04-17 06:20:36 +08:00
|
|
|
* Copyright (C) 2001, 2002 M. R. Brown
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
2006-09-27 14:49:57 +08:00
|
|
|
#include <linux/cpu.h>
|
|
|
|
#include <linux/bitmap.h>
|
2011-12-22 06:29:42 +08:00
|
|
|
#include <linux/device.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/vmalloc.h>
|
2006-09-27 11:31:01 +08:00
|
|
|
#include <linux/mm.h>
|
2006-12-01 11:01:43 +08:00
|
|
|
#include <linux/io.h>
|
2011-05-21 03:50:29 +08:00
|
|
|
#include <linux/prefetch.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/page.h>
|
2006-09-27 11:31:01 +08:00
|
|
|
#include <asm/cacheflush.h>
|
2008-07-29 07:09:44 +08:00
|
|
|
#include <cpu/sq.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
struct sq_mapping;
|
|
|
|
|
|
|
|
struct sq_mapping {
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
unsigned long sq_addr;
|
|
|
|
unsigned long addr;
|
|
|
|
unsigned int size;
|
|
|
|
|
|
|
|
struct sq_mapping *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct sq_mapping *sq_mapping_list;
|
2005-04-17 06:20:36 +08:00
|
|
|
static DEFINE_SPINLOCK(sq_mapping_lock);
|
2006-12-07 12:33:20 +08:00
|
|
|
static struct kmem_cache *sq_cache;
|
2006-09-27 14:49:57 +08:00
|
|
|
static unsigned long *sq_bitmap;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
#define store_queue_barrier() \
|
|
|
|
do { \
|
2010-01-26 11:58:40 +08:00
|
|
|
(void)__raw_readl(P4SEG_STORE_QUE); \
|
|
|
|
__raw_writel(0, P4SEG_STORE_QUE + 0); \
|
|
|
|
__raw_writel(0, P4SEG_STORE_QUE + 8); \
|
2006-09-27 14:49:57 +08:00
|
|
|
} while (0);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* sq_flush_range - Flush (prefetch) a specific SQ range
|
|
|
|
* @start: the store queue address to start flushing from
|
|
|
|
* @len: the length to flush
|
|
|
|
*
|
|
|
|
* Flushes the store queue cache from @start to @start + @len in a
|
|
|
|
* linear fashion.
|
|
|
|
*/
|
|
|
|
void sq_flush_range(unsigned long start, unsigned int len)
|
|
|
|
{
|
2007-08-21 11:25:09 +08:00
|
|
|
unsigned long *sq = (unsigned long *)start;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Flush the queues */
|
|
|
|
for (len >>= 5; len--; sq += 8)
|
2007-08-21 11:25:09 +08:00
|
|
|
prefetchw(sq);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Wait for completion */
|
2006-09-27 14:49:57 +08:00
|
|
|
store_queue_barrier();
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2006-12-01 11:01:43 +08:00
|
|
|
EXPORT_SYMBOL(sq_flush_range);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
static inline void sq_mapping_list_add(struct sq_mapping *map)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-09-27 14:49:57 +08:00
|
|
|
struct sq_mapping **p, *tmp;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
spin_lock_irq(&sq_mapping_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
p = &sq_mapping_list;
|
|
|
|
while ((tmp = *p) != NULL)
|
|
|
|
p = &tmp->next;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
map->next = tmp;
|
|
|
|
*p = map;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
spin_unlock_irq(&sq_mapping_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
static inline void sq_mapping_list_del(struct sq_mapping *map)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-09-27 14:49:57 +08:00
|
|
|
struct sq_mapping **p, *tmp;
|
|
|
|
|
|
|
|
spin_lock_irq(&sq_mapping_lock);
|
|
|
|
|
|
|
|
for (p = &sq_mapping_list; (tmp = *p); p = &tmp->next)
|
|
|
|
if (tmp == map) {
|
|
|
|
*p = tmp->next;
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
spin_unlock_irq(&sq_mapping_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2010-02-17 12:23:00 +08:00
|
|
|
static int __sq_remap(struct sq_mapping *map, pgprot_t prot)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-09-27 14:49:57 +08:00
|
|
|
#if defined(CONFIG_MMU)
|
2005-04-17 06:20:36 +08:00
|
|
|
struct vm_struct *vma;
|
|
|
|
|
|
|
|
vma = __get_vm_area(map->size, VM_ALLOC, map->sq_addr, SQ_ADDRMAX);
|
|
|
|
if (!vma)
|
2006-09-27 14:49:57 +08:00
|
|
|
return -ENOMEM;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
vma->phys_addr = map->addr;
|
|
|
|
|
2006-12-09 08:16:12 +08:00
|
|
|
if (ioremap_page_range((unsigned long)vma->addr,
|
|
|
|
(unsigned long)vma->addr + map->size,
|
2010-02-17 12:23:00 +08:00
|
|
|
vma->phys_addr, prot)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
vunmap(vma->addr);
|
2006-09-27 14:49:57 +08:00
|
|
|
return -EAGAIN;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2006-09-27 14:49:57 +08:00
|
|
|
#else
|
|
|
|
/*
|
|
|
|
* Without an MMU (or with it turned off), this is much more
|
|
|
|
* straightforward, as we can just load up each queue's QACR with
|
|
|
|
* the physical address appropriately masked.
|
|
|
|
*/
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writel(((map->addr >> 26) << 2) & 0x1c, SQ_QACR0);
|
|
|
|
__raw_writel(((map->addr >> 26) << 2) & 0x1c, SQ_QACR1);
|
2006-09-27 14:49:57 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sq_remap - Map a physical address through the Store Queues
|
|
|
|
* @phys: Physical address of mapping.
|
|
|
|
* @size: Length of mapping.
|
|
|
|
* @name: User invoking mapping.
|
2010-02-17 12:23:00 +08:00
|
|
|
* @prot: Protection bits.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* Remaps the physical address @phys through the next available store queue
|
|
|
|
* address of @size length. @name is logged at boot time as well as through
|
2006-09-27 14:49:57 +08:00
|
|
|
* the sysfs interface.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2006-09-27 14:49:57 +08:00
|
|
|
unsigned long sq_remap(unsigned long phys, unsigned int size,
|
2010-02-17 12:23:00 +08:00
|
|
|
const char *name, pgprot_t prot)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct sq_mapping *map;
|
2006-09-27 14:49:57 +08:00
|
|
|
unsigned long end;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int psz;
|
2006-09-27 14:49:57 +08:00
|
|
|
int ret, page;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Don't allow wraparound or zero size */
|
|
|
|
end = phys + size - 1;
|
2006-09-27 14:49:57 +08:00
|
|
|
if (unlikely(!size || end < phys))
|
|
|
|
return -EINVAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Don't allow anyone to remap normal memory.. */
|
2006-09-27 14:49:57 +08:00
|
|
|
if (unlikely(phys < virt_to_phys(high_memory)))
|
|
|
|
return -EINVAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
phys &= PAGE_MASK;
|
2006-09-27 14:49:57 +08:00
|
|
|
size = PAGE_ALIGN(end + 1) - phys;
|
|
|
|
|
|
|
|
map = kmem_cache_alloc(sq_cache, GFP_KERNEL);
|
|
|
|
if (unlikely(!map))
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
map->addr = phys;
|
|
|
|
map->size = size;
|
|
|
|
map->name = name;
|
|
|
|
|
2006-12-01 11:01:43 +08:00
|
|
|
page = bitmap_find_free_region(sq_bitmap, 0x04000000 >> PAGE_SHIFT,
|
2006-09-27 14:49:57 +08:00
|
|
|
get_order(map->size));
|
|
|
|
if (unlikely(page < 0)) {
|
|
|
|
ret = -ENOSPC;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
map->sq_addr = P4SEG_STORE_QUE + (page << PAGE_SHIFT);
|
|
|
|
|
2010-02-17 12:23:00 +08:00
|
|
|
ret = __sq_remap(map, prot);
|
2006-09-27 14:49:57 +08:00
|
|
|
if (unlikely(ret != 0))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
psz = (size + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
|
|
|
|
pr_info("sqremap: %15s [%4d page%s] va 0x%08lx pa 0x%08lx\n",
|
|
|
|
likely(map->name) ? map->name : "???",
|
|
|
|
psz, psz == 1 ? " " : "s",
|
|
|
|
map->sq_addr, map->addr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
sq_mapping_list_add(map);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
return map->sq_addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
out:
|
|
|
|
kmem_cache_free(sq_cache, map);
|
|
|
|
return ret;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2006-12-01 11:01:43 +08:00
|
|
|
EXPORT_SYMBOL(sq_remap);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* sq_unmap - Unmap a Store Queue allocation
|
2008-08-04 11:51:06 +08:00
|
|
|
* @vaddr: Pre-allocated Store Queue mapping.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* Unmaps the store queue allocation @map that was previously created by
|
|
|
|
* sq_remap(). Also frees up the pte that was previously inserted into
|
|
|
|
* the kernel page table and discards the UTLB translation.
|
|
|
|
*/
|
2006-09-27 14:49:57 +08:00
|
|
|
void sq_unmap(unsigned long vaddr)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-09-27 14:49:57 +08:00
|
|
|
struct sq_mapping **p, *map;
|
|
|
|
int page;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
for (p = &sq_mapping_list; (map = *p); p = &map->next)
|
|
|
|
if (map->sq_addr == vaddr)
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
if (unlikely(!map)) {
|
|
|
|
printk("%s: bad store queue address 0x%08lx\n",
|
2008-03-05 07:23:47 +08:00
|
|
|
__func__, vaddr);
|
2006-09-27 14:49:57 +08:00
|
|
|
return;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
page = (map->sq_addr - P4SEG_STORE_QUE) >> PAGE_SHIFT;
|
|
|
|
bitmap_release_region(sq_bitmap, page, get_order(map->size));
|
|
|
|
|
|
|
|
#ifdef CONFIG_MMU
|
2007-07-25 14:59:47 +08:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Tear down the VMA in the MMU case.
|
|
|
|
*/
|
|
|
|
struct vm_struct *vma;
|
|
|
|
|
|
|
|
vma = remove_vm_area((void *)(map->sq_addr & PAGE_MASK));
|
|
|
|
if (!vma) {
|
|
|
|
printk(KERN_ERR "%s: bad address 0x%08lx\n",
|
2008-03-05 07:23:47 +08:00
|
|
|
__func__, map->sq_addr);
|
2007-07-25 14:59:47 +08:00
|
|
|
return;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2006-09-27 14:49:57 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
sq_mapping_list_del(map);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
kmem_cache_free(sq_cache, map);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2006-12-01 11:01:43 +08:00
|
|
|
EXPORT_SYMBOL(sq_unmap);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
/*
|
|
|
|
* Needlessly complex sysfs interface. Unfortunately it doesn't seem like
|
|
|
|
* there is any other easy way to add things on a per-cpu basis without
|
|
|
|
* putting the directory entries somewhere stupid and having to create
|
|
|
|
* links in sysfs by hand back in to the per-cpu directories.
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
2006-09-27 14:49:57 +08:00
|
|
|
* Some day we may want to have an additional abstraction per store
|
|
|
|
* queue, but considering the kobject hell we already have to deal with,
|
|
|
|
* it's simply not worth the trouble.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
2006-09-27 14:49:57 +08:00
|
|
|
static struct kobject *sq_kobject[NR_CPUS];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
struct sq_sysfs_attr {
|
|
|
|
struct attribute attr;
|
|
|
|
ssize_t (*show)(char *buf);
|
|
|
|
ssize_t (*store)(const char *buf, size_t count);
|
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-02-08 20:20:14 +08:00
|
|
|
#define to_sq_sysfs_attr(a) container_of(a, struct sq_sysfs_attr, attr)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
static ssize_t sq_sysfs_show(struct kobject *kobj, struct attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct sq_sysfs_attr *sattr = to_sq_sysfs_attr(attr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
if (likely(sattr->show))
|
|
|
|
return sattr->show(buf);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
return -EIO;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
static ssize_t sq_sysfs_store(struct kobject *kobj, struct attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-09-27 14:49:57 +08:00
|
|
|
struct sq_sysfs_attr *sattr = to_sq_sysfs_attr(attr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
if (likely(sattr->store))
|
|
|
|
return sattr->store(buf, count);
|
|
|
|
|
|
|
|
return -EIO;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
static ssize_t mapping_show(char *buf)
|
|
|
|
{
|
|
|
|
struct sq_mapping **list, *entry;
|
|
|
|
char *p = buf;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
for (list = &sq_mapping_list; (entry = *list); list = &entry->next)
|
|
|
|
p += sprintf(p, "%08lx-%08lx [%08lx]: %s\n",
|
|
|
|
entry->sq_addr, entry->sq_addr + entry->size,
|
|
|
|
entry->addr, entry->name);
|
|
|
|
|
|
|
|
return p - buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t mapping_store(const char *buf, size_t count)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-09-27 14:49:57 +08:00
|
|
|
unsigned long base = 0, len = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
sscanf(buf, "%lx %lx", &base, &len);
|
|
|
|
if (!base)
|
|
|
|
return -EIO;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
if (likely(len)) {
|
2010-02-17 12:23:00 +08:00
|
|
|
int ret = sq_remap(base, len, "Userspace", PAGE_SHARED);
|
2006-09-27 14:49:57 +08:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
} else
|
|
|
|
sq_unmap(base);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
return count;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
static struct sq_sysfs_attr mapping_attr =
|
|
|
|
__ATTR(mapping, 0644, mapping_show, mapping_store);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
static struct attribute *sq_sysfs_attrs[] = {
|
|
|
|
&mapping_attr.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2010-01-19 09:58:23 +08:00
|
|
|
static const struct sysfs_ops sq_sysfs_ops = {
|
2006-09-27 14:49:57 +08:00
|
|
|
.show = sq_sysfs_show,
|
|
|
|
.store = sq_sysfs_store,
|
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
static struct kobj_type ktype_percpu_entry = {
|
|
|
|
.sysfs_ops = &sq_sysfs_ops,
|
|
|
|
.default_attrs = sq_sysfs_attrs,
|
|
|
|
};
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-01-10 15:24:11 +08:00
|
|
|
static int sq_dev_add(struct device *dev, struct subsys_interface *sif)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2011-12-22 06:29:42 +08:00
|
|
|
unsigned int cpu = dev->id;
|
2006-09-27 14:49:57 +08:00
|
|
|
struct kobject *kobj;
|
2007-12-18 03:54:39 +08:00
|
|
|
int error;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
sq_kobject[cpu] = kzalloc(sizeof(struct kobject), GFP_KERNEL);
|
|
|
|
if (unlikely(!sq_kobject[cpu]))
|
|
|
|
return -ENOMEM;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
kobj = sq_kobject[cpu];
|
2011-12-22 06:29:42 +08:00
|
|
|
error = kobject_init_and_add(kobj, &ktype_percpu_entry, &dev->kobj,
|
2007-12-18 03:54:39 +08:00
|
|
|
"%s", "sq");
|
|
|
|
if (!error)
|
|
|
|
kobject_uevent(kobj, KOBJ_ADD);
|
|
|
|
return error;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2012-01-10 15:24:11 +08:00
|
|
|
static int sq_dev_remove(struct device *dev, struct subsys_interface *sif)
|
2006-09-27 14:49:57 +08:00
|
|
|
{
|
2011-12-22 06:29:42 +08:00
|
|
|
unsigned int cpu = dev->id;
|
2006-09-27 14:49:57 +08:00
|
|
|
struct kobject *kobj = sq_kobject[cpu];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-12-21 00:13:05 +08:00
|
|
|
kobject_put(kobj);
|
2006-09-27 14:49:57 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-12-22 06:29:42 +08:00
|
|
|
static struct subsys_interface sq_interface = {
|
2012-01-10 15:24:11 +08:00
|
|
|
.name = "sq",
|
2011-12-22 06:29:42 +08:00
|
|
|
.subsys = &cpu_subsys,
|
|
|
|
.add_dev = sq_dev_add,
|
2012-01-10 15:24:11 +08:00
|
|
|
.remove_dev = sq_dev_remove,
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init sq_api_init(void)
|
|
|
|
{
|
2006-09-27 14:49:57 +08:00
|
|
|
unsigned int nr_pages = 0x04000000 >> PAGE_SHIFT;
|
|
|
|
unsigned int size = (nr_pages + (BITS_PER_LONG - 1)) / BITS_PER_LONG;
|
|
|
|
int ret = -ENOMEM;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
printk(KERN_NOTICE "sq: Registering store queue API.\n");
|
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
sq_cache = kmem_cache_create("store_queue_cache",
|
2007-07-20 09:11:58 +08:00
|
|
|
sizeof(struct sq_mapping), 0, 0, NULL);
|
2006-09-27 14:49:57 +08:00
|
|
|
if (unlikely(!sq_cache))
|
|
|
|
return ret;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-27 14:49:57 +08:00
|
|
|
sq_bitmap = kzalloc(size, GFP_KERNEL);
|
|
|
|
if (unlikely(!sq_bitmap))
|
|
|
|
goto out;
|
|
|
|
|
2011-12-22 06:29:42 +08:00
|
|
|
ret = subsys_interface_register(&sq_interface);
|
2006-09-27 14:49:57 +08:00
|
|
|
if (unlikely(ret != 0))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out:
|
|
|
|
kfree(sq_bitmap);
|
|
|
|
kmem_cache_destroy(sq_cache);
|
2006-08-06 03:14:45 +08:00
|
|
|
|
|
|
|
return ret;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit sq_api_exit(void)
|
|
|
|
{
|
2011-12-22 06:29:42 +08:00
|
|
|
subsys_interface_unregister(&sq_interface);
|
2006-09-27 14:49:57 +08:00
|
|
|
kfree(sq_bitmap);
|
|
|
|
kmem_cache_destroy(sq_cache);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(sq_api_init);
|
|
|
|
module_exit(sq_api_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, M. R. Brown <mrbrown@0xd6.org>");
|
|
|
|
MODULE_DESCRIPTION("Simple API for SH-4 integrated Store Queues");
|
|
|
|
MODULE_LICENSE("GPL");
|