Skip to content

Commit a6525b9

Browse files
committed
Merge tag 'mips_5.12_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux
Pull more MIPS updates from Thomas Bogendoerfer: - added n64 block driver - fix for ubsan warnings - fix for bcm63xx platform - update of linux-mips mailinglist * tag 'mips_5.12_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux: arch: mips: update references to current linux-mips list mips: bmips: init clocks earlier vmlinux.lds.h: catch even more instrumentation symbols into .data n64: store dev instance into disk private data n64: cleanup n64cart_probe() n64: cosmetics changes n64: remove curly brackets n64: use sector SECTOR_SHIFT instead 512 n64: use enums for reg n64: move module param at the top n64: move module info at the end n64: use pr_fmt to avoid duplicate string block: Add n64 cart driver
2 parents fdce296 + 057a14d commit a6525b9

8 files changed

Lines changed: 190 additions & 5 deletions

File tree

‎arch/mips/bmips/setup.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,4 @@ static int __init plat_dev_init(void)
196196
return 0;
197197
}
198198

199-
device_initcall(plat_dev_init);
199+
arch_initcall(plat_dev_init);

‎arch/mips/kernel/r4k-bugs64.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
static char bug64hit[] __initdata =
1919
"reliable operation impossible!\n%s";
2020
static char nowar[] __initdata =
21-
"Please report to <linux-mips@linux-mips.org>.";
21+
"Please report to <linux-mips@vger.kernel.org>.";
2222
static char r4kwar[] __initdata =
2323
"Enable CPU_R4000_WORKAROUNDS to rectify.";
2424
static char daddiwar[] __initdata =

‎arch/mips/lib/iomap-pci.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void __iomem *__pci_ioport_map(struct pci_dev *dev,
3232
sprintf(name, "%04x:%02x", pci_domain_nr(bus), bus->number);
3333
printk(KERN_WARNING "io_map_base of root PCI bus %s unset. "
3434
"Trying to continue but you better\nfix this issue or "
35-
"report it to linux-mips@linux-mips.org or your "
35+
"report it to linux-mips@vger.kernel.org or your "
3636
"vendor.\n", name);
3737
#ifdef CONFIG_PCI_DOMAINS
3838
panic("To avoid data corruption io_map_base MUST be set with "

‎arch/mips/sgi-ip32/ip32-irq.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static void ip32_unknown_interrupt(void)
343343
printk("Register dump:\n");
344344
show_regs(get_irq_regs());
345345

346-
printk("Please mail this report to linux-mips@linux-mips.org\n");
346+
printk("Please mail this report to linux-mips@vger.kernel.org\n");
347347
printk("Spinning...");
348348
while(1) ;
349349
}

‎drivers/block/Kconfig‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ config AMIGA_Z2RAM
6666
To compile this driver as a module, choose M here: the
6767
module will be called z2ram.
6868

69+
config N64CART
70+
bool "N64 cart support"
71+
depends on MACH_NINTENDO64
72+
help
73+
Support for the N64 cart.
74+
6975
config CDROM
7076
tristate
7177
select BLK_SCSI_REQUEST

‎drivers/block/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ obj-$(CONFIG_PS3_DISK) += ps3disk.o
1717
obj-$(CONFIG_PS3_VRAM) += ps3vram.o
1818
obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o
1919
obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o
20+
obj-$(CONFIG_N64CART) += n64cart.o
2021
obj-$(CONFIG_BLK_DEV_RAM) += brd.o
2122
obj-$(CONFIG_BLK_DEV_LOOP) += loop.o
2223
obj-$(CONFIG_XILINX_SYSACE) += xsysace.o

‎drivers/block/n64cart.c‎

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Support for the N64 cart.
4+
*
5+
* Copyright (c) 2021 Lauri Kasanen
6+
*/
7+
8+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9+
#include <linux/bitops.h>
10+
#include <linux/blkdev.h>
11+
#include <linux/dma-mapping.h>
12+
#include <linux/init.h>
13+
#include <linux/module.h>
14+
#include <linux/platform_device.h>
15+
16+
enum {
17+
PI_DRAM_REG = 0,
18+
PI_CART_REG,
19+
PI_READ_REG,
20+
PI_WRITE_REG,
21+
PI_STATUS_REG,
22+
};
23+
24+
#define PI_STATUS_DMA_BUSY (1 << 0)
25+
#define PI_STATUS_IO_BUSY (1 << 1)
26+
27+
#define CART_DOMAIN 0x10000000
28+
#define CART_MAX 0x1FFFFFFF
29+
30+
#define MIN_ALIGNMENT 8
31+
32+
static u32 __iomem *reg_base;
33+
34+
static unsigned int start;
35+
module_param(start, uint, 0);
36+
MODULE_PARM_DESC(start, "Start address of the cart block data");
37+
38+
static unsigned int size;
39+
module_param(size, uint, 0);
40+
MODULE_PARM_DESC(size, "Size of the cart block data, in bytes");
41+
42+
static void n64cart_write_reg(const u8 reg, const u32 value)
43+
{
44+
writel(value, reg_base + reg);
45+
}
46+
47+
static u32 n64cart_read_reg(const u8 reg)
48+
{
49+
return readl(reg_base + reg);
50+
}
51+
52+
static void n64cart_wait_dma(void)
53+
{
54+
while (n64cart_read_reg(PI_STATUS_REG) &
55+
(PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY))
56+
cpu_relax();
57+
}
58+
59+
/*
60+
* Process a single bvec of a bio.
61+
*/
62+
static bool n64cart_do_bvec(struct device *dev, struct bio_vec *bv, u32 pos)
63+
{
64+
dma_addr_t dma_addr;
65+
const u32 bstart = pos + start;
66+
67+
/* Alignment check */
68+
WARN_ON_ONCE((bv->bv_offset & (MIN_ALIGNMENT - 1)) ||
69+
(bv->bv_len & (MIN_ALIGNMENT - 1)));
70+
71+
dma_addr = dma_map_bvec(dev, bv, DMA_FROM_DEVICE, 0);
72+
if (dma_mapping_error(dev, dma_addr))
73+
return false;
74+
75+
n64cart_wait_dma();
76+
77+
n64cart_write_reg(PI_DRAM_REG, dma_addr + bv->bv_offset);
78+
n64cart_write_reg(PI_CART_REG, (bstart | CART_DOMAIN) & CART_MAX);
79+
n64cart_write_reg(PI_WRITE_REG, bv->bv_len - 1);
80+
81+
n64cart_wait_dma();
82+
83+
dma_unmap_page(dev, dma_addr, bv->bv_len, DMA_FROM_DEVICE);
84+
return true;
85+
}
86+
87+
static blk_qc_t n64cart_submit_bio(struct bio *bio)
88+
{
89+
struct bio_vec bvec;
90+
struct bvec_iter iter;
91+
struct device *dev = bio->bi_disk->private_data;
92+
u32 pos = bio->bi_iter.bi_sector << SECTOR_SHIFT;
93+
94+
bio_for_each_segment(bvec, bio, iter) {
95+
if (!n64cart_do_bvec(dev, &bvec, pos))
96+
goto io_error;
97+
pos += bvec.bv_len;
98+
}
99+
100+
bio_endio(bio);
101+
return BLK_QC_T_NONE;
102+
io_error:
103+
bio_io_error(bio);
104+
return BLK_QC_T_NONE;
105+
}
106+
107+
static const struct block_device_operations n64cart_fops = {
108+
.owner = THIS_MODULE,
109+
.submit_bio = n64cart_submit_bio,
110+
};
111+
112+
/*
113+
* The target device is embedded and RAM-constrained. We save RAM
114+
* by initializing in __init code that gets dropped late in boot.
115+
* For the same reason there is no module or unloading support.
116+
*/
117+
static int __init n64cart_probe(struct platform_device *pdev)
118+
{
119+
struct gendisk *disk;
120+
121+
if (!start || !size) {
122+
pr_err("start or size not specified\n");
123+
return -ENODEV;
124+
}
125+
126+
if (size & 4095) {
127+
pr_err("size must be a multiple of 4K\n");
128+
return -ENODEV;
129+
}
130+
131+
reg_base = devm_platform_ioremap_resource(pdev, 0);
132+
if (!reg_base)
133+
return -EINVAL;
134+
135+
disk = alloc_disk(0);
136+
if (!disk)
137+
return -ENOMEM;
138+
139+
disk->queue = blk_alloc_queue(NUMA_NO_NODE);
140+
if (!disk->queue)
141+
return -ENOMEM;
142+
143+
disk->first_minor = 0;
144+
disk->flags = GENHD_FL_NO_PART_SCAN | GENHD_FL_EXT_DEVT;
145+
disk->fops = &n64cart_fops;
146+
disk->private_data = &pdev->dev;
147+
strcpy(disk->disk_name, "n64cart");
148+
149+
set_capacity(disk, size >> SECTOR_SHIFT);
150+
set_disk_ro(disk, 1);
151+
152+
blk_queue_flag_set(QUEUE_FLAG_NONROT, disk->queue);
153+
blk_queue_physical_block_size(disk->queue, 4096);
154+
blk_queue_logical_block_size(disk->queue, 4096);
155+
156+
add_disk(disk);
157+
158+
pr_info("n64cart: %u kb disk\n", size / 1024);
159+
160+
return 0;
161+
}
162+
163+
static struct platform_driver n64cart_driver = {
164+
.driver = {
165+
.name = "n64cart",
166+
},
167+
};
168+
169+
static int __init n64cart_init(void)
170+
{
171+
return platform_driver_probe(&n64cart_driver, n64cart_probe);
172+
}
173+
174+
module_init(n64cart_init);
175+
176+
MODULE_AUTHOR("Lauri Kasanen <cand@gmx.com>");
177+
MODULE_DESCRIPTION("Driver for the N64 cart");
178+
MODULE_LICENSE("GPL");

‎include/asm-generic/vmlinux.lds.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
*/
9999
#if defined(CONFIG_LD_DEAD_CODE_DATA_ELIMINATION) || defined(CONFIG_LTO_CLANG)
100100
#define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
101-
#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* .data.$__unnamed_* .data.$Lubsan_*
101+
#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* .data.$__unnamed_* .data.$L*
102102
#define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
103103
#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L*
104104
#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral*

0 commit comments

Comments
 (0)