2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
** z2ram - Amiga pseudo-driver to access 16bit-RAM in ZorroII space
|
|
|
|
** as a block device, to be used as a RAM disk or swap space
|
|
|
|
**
|
|
|
|
** Copyright (C) 1994 by Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
|
|
|
**
|
|
|
|
** ++Geert: support for zorro_unused_z2ram, better range checking
|
|
|
|
** ++roman: translate accesses via an array
|
|
|
|
** ++Milan: support for ChipRAM usage
|
|
|
|
** ++yambo: converted to 2.0 kernel
|
|
|
|
** ++yambo: modularized and support added for 3 minor devices including:
|
|
|
|
** MAJOR MINOR DESCRIPTION
|
|
|
|
** ----- ----- ----------------------------------------------
|
|
|
|
** 37 0 Use Zorro II and Chip ram
|
|
|
|
** 37 1 Use only Zorro II ram
|
|
|
|
** 37 2 Use only Chip ram
|
|
|
|
** 37 4-7 Use memory list entry 1-4 (first is 0)
|
|
|
|
** ++jskov: support for 1-4th memory list entry.
|
|
|
|
**
|
|
|
|
** Permission to use, copy, modify, and distribute this software and its
|
|
|
|
** documentation for any purpose and without fee is hereby granted, provided
|
|
|
|
** that the above copyright notice appear in all copies and that both that
|
|
|
|
** copyright notice and this permission notice appear in supporting
|
|
|
|
** documentation. This software is provided "as is" without express or
|
|
|
|
** implied warranty.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEVICE_NAME "Z2RAM"
|
|
|
|
|
|
|
|
#include <linux/major.h>
|
|
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
2018-10-15 15:02:45 +00:00
|
|
|
#include <linux/blk-mq.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/bitops.h>
|
2010-06-02 12:28:52 +00:00
|
|
|
#include <linux/mutex.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2020-06-09 04:32:42 +00:00
|
|
|
#include <linux/pgtable.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <asm/setup.h>
|
|
|
|
#include <asm/amigahw.h>
|
|
|
|
|
|
|
|
#include <linux/zorro.h>
|
|
|
|
|
|
|
|
#define Z2MINOR_COMBINED (0)
|
|
|
|
#define Z2MINOR_Z2ONLY (1)
|
|
|
|
#define Z2MINOR_CHIPONLY (2)
|
|
|
|
#define Z2MINOR_MEMLIST1 (4)
|
|
|
|
#define Z2MINOR_MEMLIST2 (5)
|
|
|
|
#define Z2MINOR_MEMLIST3 (6)
|
|
|
|
#define Z2MINOR_MEMLIST4 (7)
|
2020-10-29 14:58:39 +00:00
|
|
|
#define Z2MINOR_COUNT (8) /* Move this down when adding a new minor */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#define Z2RAM_CHUNK1024 ( Z2RAM_CHUNKSIZE >> 10 )
|
|
|
|
|
2010-06-02 12:28:52 +00:00
|
|
|
static DEFINE_MUTEX(z2ram_mutex);
|
2020-10-29 14:58:39 +00:00
|
|
|
static u_long *z2ram_map = NULL;
|
|
|
|
static u_long z2ram_size = 0;
|
|
|
|
static int z2_count = 0;
|
|
|
|
static int chip_count = 0;
|
|
|
|
static int list_count = 0;
|
|
|
|
static int current_device = -1;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static DEFINE_SPINLOCK(z2ram_lock);
|
|
|
|
|
2020-10-29 14:58:40 +00:00
|
|
|
static struct gendisk *z2ram_gendisk[Z2MINOR_COUNT];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-10-15 15:02:45 +00:00
|
|
|
static blk_status_t z2_queue_rq(struct blk_mq_hw_ctx *hctx,
|
|
|
|
const struct blk_mq_queue_data *bd)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2018-10-15 15:02:45 +00:00
|
|
|
struct request *req = bd->rq;
|
|
|
|
unsigned long start = blk_rq_pos(req) << 9;
|
2020-10-29 14:58:39 +00:00
|
|
|
unsigned long len = blk_rq_cur_bytes(req);
|
2018-10-15 15:02:45 +00:00
|
|
|
|
|
|
|
blk_mq_start_request(req);
|
|
|
|
|
|
|
|
if (start + len > z2ram_size) {
|
|
|
|
pr_err(DEVICE_NAME ": bad access: block=%llu, "
|
|
|
|
"count=%u\n",
|
|
|
|
(unsigned long long)blk_rq_pos(req),
|
|
|
|
blk_rq_cur_sectors(req));
|
|
|
|
return BLK_STS_IOERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irq(&z2ram_lock);
|
|
|
|
|
|
|
|
while (len) {
|
|
|
|
unsigned long addr = start & Z2RAM_CHUNKMASK;
|
|
|
|
unsigned long size = Z2RAM_CHUNKSIZE - addr;
|
|
|
|
void *buffer = bio_data(req->bio);
|
|
|
|
|
|
|
|
if (len < size)
|
|
|
|
size = len;
|
2020-10-29 14:58:39 +00:00
|
|
|
addr += z2ram_map[start >> Z2RAM_CHUNKSHIFT];
|
2018-10-15 15:02:45 +00:00
|
|
|
if (rq_data_dir(req) == READ)
|
|
|
|
memcpy(buffer, (char *)addr, size);
|
|
|
|
else
|
|
|
|
memcpy((char *)addr, buffer, size);
|
|
|
|
start += size;
|
|
|
|
len -= size;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2018-10-15 15:02:45 +00:00
|
|
|
|
|
|
|
spin_unlock_irq(&z2ram_lock);
|
|
|
|
blk_mq_end_request(req, BLK_STS_OK);
|
|
|
|
return BLK_STS_OK;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
static void get_z2ram(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2020-10-29 14:58:39 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < Z2RAM_SIZE / Z2RAM_CHUNKSIZE; i++) {
|
|
|
|
if (test_bit(i, zorro_unused_z2ram)) {
|
|
|
|
z2_count++;
|
|
|
|
z2ram_map[z2ram_size++] =
|
|
|
|
(unsigned long)ZTWO_VADDR(Z2RAM_START) +
|
|
|
|
(i << Z2RAM_CHUNKSHIFT);
|
|
|
|
clear_bit(i, zorro_unused_z2ram);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
return;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
static void get_chipram(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
while (amiga_chip_avail() > (Z2RAM_CHUNKSIZE * 4)) {
|
|
|
|
chip_count++;
|
|
|
|
z2ram_map[z2ram_size] =
|
|
|
|
(u_long) amiga_chip_alloc(Z2RAM_CHUNKSIZE, "z2ram");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
if (z2ram_map[z2ram_size] == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
z2ram_size++;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
return;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2023-06-08 11:02:55 +00:00
|
|
|
static int z2_open(struct gendisk *disk, blk_mode_t mode)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2023-06-08 11:02:36 +00:00
|
|
|
int device = disk->first_minor;
|
2020-10-29 14:58:39 +00:00
|
|
|
int max_z2_map = (Z2RAM_SIZE / Z2RAM_CHUNKSIZE) * sizeof(z2ram_map[0]);
|
|
|
|
int max_chip_map = (amiga_chip_size / Z2RAM_CHUNKSIZE) *
|
|
|
|
sizeof(z2ram_map[0]);
|
|
|
|
int rc = -ENOMEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
mutex_lock(&z2ram_mutex);
|
|
|
|
if (current_device != -1 && current_device != device) {
|
|
|
|
rc = -EBUSY;
|
|
|
|
goto err_out;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
if (current_device == -1) {
|
|
|
|
z2_count = 0;
|
|
|
|
chip_count = 0;
|
|
|
|
list_count = 0;
|
|
|
|
z2ram_size = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
/* Use a specific list entry. */
|
|
|
|
if (device >= Z2MINOR_MEMLIST1 && device <= Z2MINOR_MEMLIST4) {
|
|
|
|
int index = device - Z2MINOR_MEMLIST1 + 1;
|
|
|
|
unsigned long size, paddr, vaddr;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
if (index >= m68k_realnum_memory) {
|
|
|
|
printk(KERN_ERR DEVICE_NAME
|
|
|
|
": no such entry in z2ram_map\n");
|
|
|
|
goto err_out;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
paddr = m68k_memory[index].addr;
|
|
|
|
size = m68k_memory[index].size & ~(Z2RAM_CHUNKSIZE - 1);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
#ifdef __powerpc__
|
|
|
|
/* FIXME: ioremap doesn't build correct memory tables. */
|
|
|
|
{
|
|
|
|
vfree(vmalloc(size));
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
vaddr = (unsigned long)ioremap_wt(paddr, size);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
#else
|
|
|
|
vaddr =
|
|
|
|
(unsigned long)z_remap_nocache_nonser(paddr, size);
|
|
|
|
#endif
|
|
|
|
z2ram_map =
|
|
|
|
kmalloc_array(size / Z2RAM_CHUNKSIZE,
|
|
|
|
sizeof(z2ram_map[0]), GFP_KERNEL);
|
|
|
|
if (z2ram_map == NULL) {
|
|
|
|
printk(KERN_ERR DEVICE_NAME
|
|
|
|
": cannot get mem for z2ram_map\n");
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (size) {
|
|
|
|
z2ram_map[z2ram_size++] = vaddr;
|
|
|
|
size -= Z2RAM_CHUNKSIZE;
|
|
|
|
vaddr += Z2RAM_CHUNKSIZE;
|
|
|
|
list_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (z2ram_size != 0)
|
|
|
|
printk(KERN_INFO DEVICE_NAME
|
|
|
|
": using %iK List Entry %d Memory\n",
|
|
|
|
list_count * Z2RAM_CHUNK1024, index);
|
|
|
|
} else
|
|
|
|
switch (device) {
|
|
|
|
case Z2MINOR_COMBINED:
|
|
|
|
|
|
|
|
z2ram_map =
|
|
|
|
kmalloc(max_z2_map + max_chip_map,
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (z2ram_map == NULL) {
|
|
|
|
printk(KERN_ERR DEVICE_NAME
|
|
|
|
": cannot get mem for z2ram_map\n");
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
get_z2ram();
|
|
|
|
get_chipram();
|
|
|
|
|
|
|
|
if (z2ram_size != 0)
|
|
|
|
printk(KERN_INFO DEVICE_NAME
|
|
|
|
": using %iK Zorro II RAM and %iK Chip RAM (Total %dK)\n",
|
|
|
|
z2_count * Z2RAM_CHUNK1024,
|
|
|
|
chip_count * Z2RAM_CHUNK1024,
|
|
|
|
(z2_count +
|
|
|
|
chip_count) * Z2RAM_CHUNK1024);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Z2MINOR_Z2ONLY:
|
|
|
|
z2ram_map = kmalloc(max_z2_map, GFP_KERNEL);
|
2021-06-09 12:27:39 +00:00
|
|
|
if (!z2ram_map)
|
2020-10-29 14:58:39 +00:00
|
|
|
goto err_out;
|
|
|
|
|
|
|
|
get_z2ram();
|
|
|
|
|
|
|
|
if (z2ram_size != 0)
|
|
|
|
printk(KERN_INFO DEVICE_NAME
|
|
|
|
": using %iK of Zorro II RAM\n",
|
|
|
|
z2_count * Z2RAM_CHUNK1024);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Z2MINOR_CHIPONLY:
|
|
|
|
z2ram_map = kmalloc(max_chip_map, GFP_KERNEL);
|
2021-06-09 12:27:39 +00:00
|
|
|
if (!z2ram_map)
|
2020-10-29 14:58:39 +00:00
|
|
|
goto err_out;
|
|
|
|
|
|
|
|
get_chipram();
|
|
|
|
|
|
|
|
if (z2ram_size != 0)
|
|
|
|
printk(KERN_INFO DEVICE_NAME
|
|
|
|
": using %iK Chip RAM\n",
|
|
|
|
chip_count * Z2RAM_CHUNK1024);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
rc = -ENODEV;
|
|
|
|
goto err_out;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (z2ram_size == 0) {
|
|
|
|
printk(KERN_NOTICE DEVICE_NAME
|
|
|
|
": no unused ZII/Chip RAM found\n");
|
|
|
|
goto err_out_kfree;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
current_device = device;
|
|
|
|
z2ram_size <<= Z2RAM_CHUNKSHIFT;
|
2020-10-29 14:58:40 +00:00
|
|
|
set_capacity(z2ram_gendisk[device], z2ram_size >> 9);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
mutex_unlock(&z2ram_mutex);
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
err_out_kfree:
|
2020-10-29 14:58:39 +00:00
|
|
|
kfree(z2ram_map);
|
2005-04-16 22:20:36 +00:00
|
|
|
err_out:
|
2020-10-29 14:58:39 +00:00
|
|
|
mutex_unlock(&z2ram_mutex);
|
|
|
|
return rc;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2023-06-08 11:02:37 +00:00
|
|
|
static void z2_release(struct gendisk *disk)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2020-10-29 14:58:39 +00:00
|
|
|
mutex_lock(&z2ram_mutex);
|
|
|
|
if (current_device == -1) {
|
|
|
|
mutex_unlock(&z2ram_mutex);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mutex_unlock(&z2ram_mutex);
|
|
|
|
/*
|
|
|
|
* FIXME: unmap memory
|
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
static const struct block_device_operations z2_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = z2_open,
|
|
|
|
.release = z2_release,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2018-10-15 15:02:45 +00:00
|
|
|
static struct blk_mq_tag_set tag_set;
|
|
|
|
|
|
|
|
static const struct blk_mq_ops z2_mq_ops = {
|
2020-10-29 14:58:39 +00:00
|
|
|
.queue_rq = z2_queue_rq,
|
2018-10-15 15:02:45 +00:00
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:40 +00:00
|
|
|
static int z2ram_register_disk(int minor)
|
|
|
|
{
|
|
|
|
struct gendisk *disk;
|
2021-11-03 23:04:30 +00:00
|
|
|
int err;
|
2020-10-29 14:58:40 +00:00
|
|
|
|
2024-02-13 07:34:20 +00:00
|
|
|
disk = blk_mq_alloc_disk(&tag_set, NULL, NULL);
|
2021-06-02 06:53:45 +00:00
|
|
|
if (IS_ERR(disk))
|
|
|
|
return PTR_ERR(disk);
|
2020-10-29 14:58:40 +00:00
|
|
|
|
|
|
|
disk->major = Z2RAM_MAJOR;
|
|
|
|
disk->first_minor = minor;
|
2021-06-02 06:53:45 +00:00
|
|
|
disk->minors = 1;
|
2021-11-22 13:06:22 +00:00
|
|
|
disk->flags |= GENHD_FL_NO_PART;
|
2020-10-29 14:58:40 +00:00
|
|
|
disk->fops = &z2_fops;
|
|
|
|
if (minor)
|
|
|
|
sprintf(disk->disk_name, "z2ram%d", minor);
|
|
|
|
else
|
|
|
|
sprintf(disk->disk_name, "z2ram");
|
|
|
|
|
|
|
|
z2ram_gendisk[minor] = disk;
|
2021-11-03 23:04:30 +00:00
|
|
|
err = add_disk(disk);
|
|
|
|
if (err)
|
2022-06-19 06:05:52 +00:00
|
|
|
put_disk(disk);
|
2021-11-03 23:04:30 +00:00
|
|
|
return err;
|
2020-10-29 14:58:40 +00:00
|
|
|
}
|
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
static int __init z2_init(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2020-10-29 14:58:40 +00:00
|
|
|
int ret, i;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
if (!MACH_IS_AMIGA)
|
|
|
|
return -ENODEV;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
if (register_blkdev(Z2RAM_MAJOR, DEVICE_NAME))
|
2020-10-29 14:58:40 +00:00
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
tag_set.ops = &z2_mq_ops;
|
|
|
|
tag_set.nr_hw_queues = 1;
|
|
|
|
tag_set.nr_maps = 1;
|
|
|
|
tag_set.queue_depth = 16;
|
|
|
|
tag_set.numa_node = NUMA_NO_NODE;
|
|
|
|
tag_set.flags = BLK_MQ_F_SHOULD_MERGE;
|
|
|
|
ret = blk_mq_alloc_tag_set(&tag_set);
|
|
|
|
if (ret)
|
|
|
|
goto out_unregister_blkdev;
|
|
|
|
|
|
|
|
for (i = 0; i < Z2MINOR_COUNT; i++) {
|
|
|
|
ret = z2ram_register_disk(i);
|
|
|
|
if (ret && i == 0)
|
|
|
|
goto out_free_tagset;
|
2020-10-29 14:58:39 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:40 +00:00
|
|
|
out_free_tagset:
|
|
|
|
blk_mq_free_tag_set(&tag_set);
|
|
|
|
out_unregister_blkdev:
|
2020-10-29 14:58:39 +00:00
|
|
|
unregister_blkdev(Z2RAM_MAJOR, DEVICE_NAME);
|
|
|
|
return ret;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-10-11 16:28:47 +00:00
|
|
|
static void __exit z2_exit(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2020-10-29 14:58:39 +00:00
|
|
|
int i, j;
|
2020-10-29 14:58:40 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
unregister_blkdev(Z2RAM_MAJOR, DEVICE_NAME);
|
2020-10-29 14:58:40 +00:00
|
|
|
|
|
|
|
for (i = 0; i < Z2MINOR_COUNT; i++) {
|
|
|
|
del_gendisk(z2ram_gendisk[i]);
|
|
|
|
put_disk(z2ram_gendisk[i]);
|
|
|
|
}
|
2020-10-29 14:58:39 +00:00
|
|
|
blk_mq_free_tag_set(&tag_set);
|
|
|
|
|
|
|
|
if (current_device != -1) {
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
for (j = 0; j < z2_count; j++) {
|
|
|
|
set_bit(i++, zorro_unused_z2ram);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
for (j = 0; j < chip_count; j++) {
|
|
|
|
if (z2ram_map[i]) {
|
|
|
|
amiga_chip_free((void *)z2ram_map[i++]);
|
|
|
|
}
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
if (z2ram_map != NULL) {
|
|
|
|
kfree(z2ram_map);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2020-10-29 14:58:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-10-11 16:28:47 +00:00
|
|
|
|
|
|
|
module_init(z2_init);
|
|
|
|
module_exit(z2_exit);
|
2024-06-18 01:13:34 +00:00
|
|
|
MODULE_DESCRIPTION("Amiga Zorro II ramdisk driver");
|
2006-10-11 16:28:47 +00:00
|
|
|
MODULE_LICENSE("GPL");
|