Skip to contentSkip to conversation

SWIM driver fixes

PATCH Superseded Finn Thain 8 participants 43 messages Apr 1, 2018 – Apr 10, 2018

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Finn Thain

author
#0 lore raw

cover SWIM driver fixes

This patch series has fixes for bugs in the SWIM floppy disk controller driver, including an oops and a soft lockup.

There are also patches to add support for SWIM devices connected to IOPs.

Geert, would you please take this series through the m68k tree once the necessary "acked-by" tags arrive?

Jens, I've Cc'd you too because there's no official maintainer for drivers/block/swim.c and none for the drivers/block/ directory either.

The series could be separated into m68k patches and block driver patches and sent through different trees if that's preferred.

I did not do so because "acked-by" tags would still be needed and because separating patches 4 and 5 didn't make much sense.

Finn Thain (12):
m68k/mac: Revisit floppy disc controller base addresses m68k/mac: Fix SWIM memory resource end address m68k/mac: Don't remap SWIM MMIO region
m68k/mac: Place ISM IOP in bypass mode
block/swim: Use HEDSEL bit in ISM mode register block/swim: Fix array bounds check
block/swim: Remove extra put_disk() call from error path block/swim: Don't log an error message for an invalid ioctl block/swim: Rename macros to avoid inconsistent inverted logic block/swim: Check drive type
block/swim: Fix IO error at end of medium block/swim: Select appropriate drive on device open

 arch/m68k/include/asm/macintosh.h |  10 +--
 arch/m68k/mac/config.c            | 126 ++++++++++++++++++++------------------
 arch/m68k/mac/iop.c               |   8 ++-
 drivers/block/swim.c              |  69 +++++++++++----------
 drivers/block/swim3.c             |   6 +-
 5 files changed, 118 insertions(+), 101 deletions(-)
Signature · 1 line
2.16.1
author
#27 lore raw

PATCH 9/12 block/swim: Rename macros to avoid inconsistent inverted logic

The Sony drive status bits use active-low logic. The swim_readbit() function converts that to 'C' logic for readability. Hence, the sense of the names of the status bit macros should not be inverted.

Mostly they are correct. However, the TWOMEG_DRIVE, MFM_MODE and TWOMEG_MEDIA macros have inverted sense (like MkLinux). Fix this inconsistency and make the following patches less confusing.

The same problem affects swim3.c so fix that too.

No functional change.

The FDHD drive status bits are documented in sonydriv.cpp from MAME and in swimiii.h from MkLinux.

Cc Laurent Vivier <[email protected]>
Cc Benjamin Herrenschmidt <[email protected]>
Cc Jens Axboe <[email protected]>
---
 drivers/block/swim.c  | 8 ++++----
 drivers/block/swim3.c | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/block/swim.c +4 -4
index 8be0d92bc431..d69cc5dadbfc 100644
@@ -111,7 +111,7 @@ struct iwm {
 /* Select values for swim_select and swim_readbit */
 
 #define READ_DATA_0	0x074
-#define TWOMEG_DRIVE	0x075
+#define ONEMEG_DRIVE	0x075
 #define SINGLE_SIDED	0x076
 #define DRIVE_PRESENT	0x077
 #define DISK_IN		0x170
@@ -119,9 +119,9 @@ struct iwm {
 #define TRACK_ZERO	0x172
 #define TACHO		0x173
 #define READ_DATA_1	0x174
-#define MFM_MODE	0x175
+#define GCR_MODE	0x175
 #define SEEK_COMPLETE	0x176
-#define ONEMEG_MEDIA	0x177
+#define TWOMEG_MEDIA	0x177
 
 /* Bits in handshake register */
 
@@ -619,7 +619,7 @@ static void setup_medium(struct floppy_state *fs)
 		struct floppy_struct *g;
 		fs->disk_in = 1;
 		fs->write_protected = swim_readbit(base, WRITE_PROT);
-		fs->type = swim_readbit(base, ONEMEG_MEDIA);
+		fs->type = swim_readbit(base, TWOMEG_MEDIA);
 
 		if (swim_track00(base))
 			printk(KERN_ERR
drivers/block/swim3.c +3 -3
index af51015d056e..469541c1e51e 100644
@@ -148,7 +148,7 @@ struct swim3 {
 #define MOTOR_ON	2
 #define RELAX		3	/* also eject in progress */
 #define READ_DATA_0	4
-#define TWOMEG_DRIVE	5
+#define ONEMEG_DRIVE	5
 #define SINGLE_SIDED	6	/* drive or diskette is 4MB type? */
 #define DRIVE_PRESENT	7
 #define DISK_IN		8
@@ -156,9 +156,9 @@ struct swim3 {
 #define TRACK_ZERO	10
 #define TACHO		11
 #define READ_DATA_1	12
-#define MFM_MODE	13
+#define GCR_MODE	13
 #define SEEK_COMPLETE	14
-#define ONEMEG_MEDIA	15
+#define TWOMEG_MEDIA	15
 
 /* Definitions of values used in writing and formatting */
 #define DATA_ESCAPE	0x99
Signature · 1 line
2.16.1
author
#3 lore raw

PATCH 2/12 m68k/mac: Fix SWIM memory resource end address

In reply to Finn Thain

The resource size is 0x2000 == end - start + 1. Therefore end == start + 0x2000 - 1.

---
 arch/m68k/mac/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/m68k/mac/config.c +1 -1
index 54f3a8421afc..1aba633b7268 100644
@@ -1007,7 +1007,7 @@ int __init mac_platform_init(void)
 		struct resource swim_rsrc = {
 			.flags = IORESOURCE_MEM,
 			.start = (resource_size_t)swim_base,
-			.end   = (resource_size_t)swim_base + 0x2000,
+			.end   = (resource_size_t)swim_base + 0x1FFF,
 		};
 
 		platform_device_register_simple("swim", -1, &swim_rsrc, 1);
Signature · 1 line
2.16.1
author
#12 lore raw

PATCH 4/12 m68k/mac: Place ISM IOP in bypass mode

In reply to Finn Thain

Some Mac models have an IOP for offloading floppy disk IO. Linux once had a driver for that but it got removed in commit b21a323710e7 ("[PATCH] remove the broken BLK_DEV_SWIM_IOP driver").

Put the ISM IOP into bypass mode so that the existing 'swim_mod' driver can access the controller directly. Use the appropriate macros for the flag bits.

---
 arch/m68k/mac/iop.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/m68k/mac/iop.c +5 -2
index 9bfa17015768..7864dcca5891 100644
@@ -234,6 +234,7 @@ static struct iop_msg *iop_get_unused_msg(void)
  * is to find and initialize the IOPs early in the boot sequence, so that
  * the serial IOP can be placed into bypass mode _before_ we try to
  * initialize the serial console.
+ * The ISM IOP is put into bypass mode for compatibility with the swim driver.
  */
 
 void __init iop_preinit(void)
@@ -244,7 +245,8 @@ void __init iop_preinit(void)
 		} else {
 			iop_base[IOP_NUM_SCC] = (struct mac_iop *) SCC_IOP_BASE_QUADRA;
 		}
-		iop_base[IOP_NUM_SCC]->status_ctrl = 0x87;
+		iop_base[IOP_NUM_SCC]->status_ctrl = IOP_BYPASS | IOP_AUTOINC |
+						     IOP_RUN | IOP_DMAINACTIVE;
 		iop_scc_present = 1;
 	} else {
 		iop_base[IOP_NUM_SCC] = NULL;
@@ -256,7 +258,8 @@ void __init iop_preinit(void)
 		} else {
 			iop_base[IOP_NUM_ISM] = (struct mac_iop *) ISM_IOP_BASE_QUADRA;
 		}
-		iop_base[IOP_NUM_ISM]->status_ctrl = 0;
+		iop_base[IOP_NUM_ISM]->status_ctrl = IOP_BYPASS | IOP_AUTOINC |
+						     IOP_RUN | IOP_DMAINACTIVE;
 		iop_ism_present = 1;
 	} else {
 		iop_base[IOP_NUM_ISM] = NULL;
Signature · 1 line
2.16.1
author
#30 lore raw

PATCH 11/12 block/swim: Fix IO error at end of medium

In reply to Finn Thain

Reading to the end of a 720K disk results in an IO error instead of EOF because the block layer thinks the disk has 2880 sectors. (Partly this is a result of inverted logic of the ONEMEG_MEDIA bit that's now fixed.)

Initialize the density and head count in swim_add_floppy() to agree with the device size passed to set_capacity() during drive probe.

Call set_capacity() again upon device open, after refreshing the density and head count values.

---
 drivers/block/swim.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/block/swim.c +8 -5
index 6e3ebf5519e3..c4eb54575574 100644
@@ -619,7 +619,6 @@ static void setup_medium(struct floppy_state *fs)
 		struct floppy_struct *g;
 		fs->disk_in = 1;
 		fs->write_protected = swim_readbit(base, WRITE_PROT);
-		fs->type = swim_readbit(base, TWOMEG_MEDIA);
 
 		if (swim_track00(base))
 			printk(KERN_ERR
@@ -627,6 +626,9 @@ static void setup_medium(struct floppy_state *fs)
 
 		swim_track00(base);
 
+		fs->type = swim_readbit(base, TWOMEG_MEDIA) ?
+			HD_MEDIA : DD_MEDIA;
+		fs->head_number = swim_readbit(base, SINGLE_SIDED) ? 1 : 2;
 		get_floppy_geometry(fs, 0, &g);
 		fs->total_secs = g->size;
 		fs->secpercyl = g->head * g->sect;
@@ -668,6 +670,8 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
 		goto out;
 	}
 
+	set_capacity(fs->disk, fs->total_secs);
+
 	if (mode & FMODE_NDELAY)
 		return 0;
 
@@ -820,10 +824,9 @@ static int swim_add_floppy(struct swim_priv *swd, enum drive_location location)
 
 	swim_motor(base, OFF);
 
-	if (swim_readbit(base, SINGLE_SIDED))
-		fs->head_number = 1;
-	else
-		fs->head_number = 2;
+	fs->type = HD_MEDIA;
+	fs->head_number = 2;
+
 	fs->ref_count = 0;
 	fs->ejected = 1;
 
Signature · 1 line
2.16.1
author
#32 lore raw

PATCH 12/12 block/swim: Select appropriate drive on device open

In reply to Finn Thain
---
 drivers/block/swim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/swim.c +1 -1
index c4eb54575574..64226c56ffb2 100644
@@ -660,7 +660,7 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
 		swim_write(base, setup, S_IBM_DRIVE | S_FCLK_DIV2);
 
 	udelay(10);
-	swim_drive(base, INTERNAL_DRIVE);
+	swim_drive(base, fs->location);
 	swim_motor(base, ON);
 	swim_action(base, SETMFM);
 	if (fs->ejected)
Signature · 1 line
2.16.1
author
#28 lore raw

PATCH 10/12 block/swim: Check drive type

In reply to Finn Thain

The SWIM chip is compatible with GCR-mode Sony 400K/800K drives but this driver only supports MFM mode. Therefore only Sony FDHD drives are supported. Skip incompatible drives.

---
 drivers/block/swim.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/block/swim.c +4 -2
index d69cc5dadbfc..6e3ebf5519e3 100644
@@ -841,10 +841,12 @@ static int swim_floppy_init(struct swim_priv *swd)
 	/* scan floppy drives */
 
 	swim_drive(base, INTERNAL_DRIVE);
-	if (swim_readbit(base, DRIVE_PRESENT))
+	if (swim_readbit(base, DRIVE_PRESENT) &&
+	    !swim_readbit(base, ONEMEG_DRIVE))
 		swim_add_floppy(swd, INTERNAL_DRIVE);
 	swim_drive(base, EXTERNAL_DRIVE);
-	if (swim_readbit(base, DRIVE_PRESENT))
+	if (swim_readbit(base, DRIVE_PRESENT) &&
+	    !swim_readbit(base, ONEMEG_DRIVE))
 		swim_add_floppy(swd, EXTERNAL_DRIVE);
 
 	/* register floppy drives */
Signature · 1 line
2.16.1
author
#23 lore raw

PATCH 8/12 block/swim: Don't log an error message for an invalid ioctl

In reply to Finn Thain

The 'eject' shell command may send various different ioctl commands. This leads to error messages on the console even though the FDEJECT ioctl succeeds.

~# eject floppy
SWIM floppy_ioctl: unknown cmd 21257
SWIM floppy_ioctl: unknown cmd 1

Don't log an error message for an invalid ioctl, just do as the swim3 driver does and return -ENOTTY.

---
 drivers/block/swim.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/block/swim.c +2 -7
index 19d7d27468c7..8be0d92bc431 100644
@@ -739,14 +739,9 @@ static int floppy_ioctl(struct block_device *bdev, fmode_t mode,
 		if (copy_to_user((void __user *) param, (void *) &floppy_type,
 				 sizeof(struct floppy_struct)))
 			return -EFAULT;
-		break;
-
-	default:
-		printk(KERN_DEBUG "SWIM floppy_ioctl: unknown cmd %d\n",
-		       cmd);
-		return -ENOSYS;
+		return 0;
 	}
-	return 0;
+	return -ENOTTY;
 }
 
 static int floppy_getgeo(struct block_device *bdev, struct hd_geometry *geo)
Signature · 1 line
2.16.1
author
#20 lore raw

PATCH 7/12 block/swim: Remove extra put_disk() call from error path

In reply to Finn Thain
---
 drivers/block/swim.c | 1 -
 1 file changed, 1 deletion(-)
drivers/block/swim.c +0 -1
index 87c70fcce875..19d7d27468c7 100644
@@ -873,7 +873,6 @@ static int swim_floppy_init(struct swim_priv *swd)
 							      &swd->lock);
 		if (!swd->unit[drive].disk->queue) {
 			err = -ENOMEM;
-			put_disk(swd->unit[drive].disk);
 			goto exit_put_disks;
 		}
 		blk_queue_bounce_limit(swd->unit[drive].disk->queue,
Signature · 1 line
2.16.1
author
#16 lore raw

PATCH 6/12 block/swim: Fix array bounds check

In reply to Finn Thain

In the floppy_find() function in swim.c is a call to get_disk(swd->unit[drive].disk). The actual parameter to this call can be a NULL pointer when drive == swd->floppy_count. This causes an oops in get_disk().

Data read fault at 0x00000198 in Super Data (pc=0x1be5b6) BAD KERNEL BUSERR

Oops: 00000000
Modules linked in: swim_mod ipv6 mac8390
PC: [<001be5b6>] get_disk+0xc/0x76
SR: 2004  SP: 9a078bc1  a2: 0213ed90
d0: 00000000    d1: 00000000    d2: 00000000    d3: 000000ff
d4: 00000002    d5: 02983590    a0: 02332e00    a1: 022dfd64

Process dd (pid: 285, task=020ab25b)
Frame format=B ssw=074d isc=4a88 isb=6732 daddr=00000198 dobuf=00000000 baddr=001be5bc dibuf=bfffffff ver=f
Stack from 022dfca4:

        00000000 0203fc00 0213ed90 022dfcc0 02982936 00000000 00200000 022dfd08
        0020f85a 00200000 022dfd64 02332e00 004040fc 00000014 001be77e 022dfd64
        00334e4a 001be3f8 0800001d 022dfd64 01c04b60 01c04b70 022aba80 029828f8
        02332e00 022dfd2c 001be7ac 0203fc00 00200000 022dfd64 02103a00 01c04b60
        01c04b60 0200e400 022dfd68 000e191a 00200000 022dfd64 02103a00 0800001d
        00000000 00000003 000b89de 00500000 02103a00 01c04b60 02103a08 01c04c2e
Call Trace: [<02982936>] floppy_find+0x3e/0x4a [swim_mod]
 [<00200000>] uart_remove_one_port+0x1a2/0x260
 [<0020f85a>] kobj_lookup+0xde/0x132
 [<00200000>] uart_remove_one_port+0x1a2/0x260
 [<001be77e>] get_gendisk+0x0/0x130
 [<00334e4a>] mutex_lock+0x0/0x2e
 [<001be3f8>] disk_block_events+0x0/0x6c
 [<029828f8>] floppy_find+0x0/0x4a [swim_mod]
 [<001be7ac>] get_gendisk+0x2e/0x130
 [<00200000>] uart_remove_one_port+0x1a2/0x260
 [<000e191a>] __blkdev_get+0x32/0x45a
 [<00200000>] uart_remove_one_port+0x1a2/0x260
 [<000b89de>] complete_walk+0x0/0x8a
 [<000e1e22>] blkdev_get+0xe0/0x29a
 [<000e1fdc>] blkdev_open+0x0/0xb0
 [<000b89de>] complete_walk+0x0/0x8a
 [<000e1fdc>] blkdev_open+0x0/0xb0
 [<000e01cc>] bd_acquire+0x74/0x8a
 [<000e205c>] blkdev_open+0x80/0xb0
 [<000e1fdc>] blkdev_open+0x0/0xb0
 [<000abf24>] do_dentry_open+0x1a4/0x322
 [<00020000>] __do_proc_douintvec+0x22/0x27e
 [<000b89de>] complete_walk+0x0/0x8a
 [<000baa62>] link_path_walk+0x0/0x48e
 [<000ba3f8>] inode_permission+0x20/0x54
 [<000ac0e4>] vfs_open+0x42/0x78
 [<000bc372>] path_openat+0x2b2/0xeaa
 [<000bc0c0>] path_openat+0x0/0xeaa
 [<0004463e>] __irq_wake_thread+0x0/0x4e
 [<0003a45a>] task_tick_fair+0x18/0xc8
 [<000bd00a>] do_filp_open+0xa0/0xea
 [<000abae0>] do_sys_open+0x11a/0x1ee
 [<00020000>] __do_proc_douintvec+0x22/0x27e
 [<000abbf4>] SyS_open+0x1e/0x22
 [<00020000>] __do_proc_douintvec+0x22/0x27e
 [<00002b40>] syscall+0x8/0xc
 [<00020000>] __do_proc_douintvec+0x22/0x27e
 [<0000c00b>] dyadic+0x1/0x28
Code: 4e5e 4e75 4e56 fffc 2f0b 2f02 266e 0008 <206b> 0198 4a88 6732 2428 002c 661e 486b 0058 4eb9 0032 0b96 588f 4a88 672c 2008

Disabling lock debugging due to kernel taint

Fix the array index bounds check to avoid this.

Fixes 8852ecd97488 ("[PATCH] m68k: mac - Add SWIM floppy support")
Cc Laurent Vivier <[email protected]>
Cc Jens Axboe <[email protected]>
---
 drivers/block/swim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/swim.c +1 -1
index 3e3e72b141d3..87c70fcce875 100644
@@ -807,7 +807,7 @@ static struct kobject *floppy_find(dev_t dev, int *part, void *data)
 	struct swim_priv *swd = data;
 	int drive = (*part & 3);
 
-	if (drive > swd->floppy_count)
+	if (drive >= swd->floppy_count)
 		return NULL;
 
 	*part = 0;
Signature · 1 line
2.16.1
author
#14 lore raw

PATCH 5/12 block/swim: Use HEDSEL bit in ISM mode register

In reply to Finn Thain

The floppy drive 'HEDSEL' line is normally connected to VIA1 but some models don't do this. According to 'The Guide to Macintosh Family Hardware', on the Mac IIfx the SWIM device has to generate this signal.

---
 arch/m68k/mac/iop.c  |  1 +
 drivers/block/swim.c | 20 ++++++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)
arch/m68k/mac/iop.c +1 -0
index 7864dcca5891..23cf89da0c2d 100644
@@ -130,6 +130,7 @@
 /* Non-zero if the IOPs are present */
 
 int iop_scc_present, iop_ism_present;
+EXPORT_SYMBOL(iop_ism_present);
 
 /* structure for tracking channel listeners */
 
drivers/block/swim.c +16 -4
index ef4361dc5b26..3e3e72b141d3 100644
@@ -27,6 +27,7 @@
 #include <linux/platform_device.h>
 
 #include <asm/mac_via.h>
+#include <asm/mac_iop.h>
 
 #define CARDNAME "swim"
 
@@ -135,7 +136,8 @@ struct iwm {
 
 /* bits in setup register */
 
-#define S_INV_WDATA	0x01
+#define S_Q3_OUTPUT	0x01 /* SWIM */
+#define S_INV_WDATA	0x01 /* SWIM 2 */
 #define S_3_5_SELECT	0x02
 #define S_GCR		0x04
 #define S_FCLK_DIV2	0x08
@@ -273,8 +275,13 @@ static inline void swim_select(struct swim __iomem *base, int sel)
 {
 	swim_write(base, phase, RELAX);
 
-	via1_set_head(sel & 0x100);
-
+	if (iop_ism_present) {
+		if (sel & 0x100)
+			swim_write(base, mode1, HEDSEL);
+		else
+			swim_write(base, mode0, HEDSEL);
+	} else
+		via1_set_head(sel & 0x100);
 	swim_write(base, phase, sel & CA_MASK);
 }
 
@@ -644,7 +651,12 @@ static int floppy_open(struct block_device *bdev, fmode_t mode)
 	else
 		fs->ref_count++;
 
-	swim_write(base, setup, S_IBM_DRIVE  | S_FCLK_DIV2);
+	if (iop_ism_present)
+		swim_write(base, setup, S_IBM_DRIVE | S_FCLK_DIV2 |
+			   S_Q3_OUTPUT);
+	else
+		swim_write(base, setup, S_IBM_DRIVE | S_FCLK_DIV2);
+
 	udelay(10);
 	swim_drive(base, INTERNAL_DRIVE);
 	swim_motor(base, ON);
Signature · 1 line
2.16.1
author
#1 lore raw

PATCH 1/12 m68k/mac: Revisit floppy disc controller base addresses

In reply to Finn Thain

Rename floppy_type macros to make them more consistent with the scsi_type macros, which are named after classes of models with similar memory maps.

The documentation for LC-class machines has the IO devices at offsets from $50F0 0000. Use these addresses (consistent with mac_scsi resources) because they may not be aliased elsewhere in the memory map, e.g. at offsets from $5000 0000.

Add comments with controller type information from 'Designing Cards and Drivers for the Macintosh Family', relevant Developer Notes and
http://mess.redump.net/mess/driver_info/mac_technical_notes

---
 arch/m68k/include/asm/macintosh.h |  10 +--
 arch/m68k/mac/config.c            | 124 ++++++++++++++++++++------------------
 2 files changed, 70 insertions(+), 64 deletions(-)
arch/m68k/include/asm/macintosh.h +5 -5
index 9b840c03ebb7..a61ce06c0a54 100644
@@ -79,11 +79,11 @@ struct mac_model
 #define MAC_EXP_PDS_NUBUS	3 /* Accepts PDS card and/or NuBus card(s) */
 #define MAC_EXP_PDS_COMM	4 /* Accepts PDS card or Comm Slot card */
 
-#define MAC_FLOPPY_IWM		0
-#define MAC_FLOPPY_SWIM_ADDR1	1
-#define MAC_FLOPPY_SWIM_ADDR2	2
-#define MAC_FLOPPY_SWIM_IOP	3
-#define MAC_FLOPPY_AV		4
+#define MAC_FLOPPY_UNSUPPORTED	0
+#define MAC_FLOPPY_QUADRA	1
+#define MAC_FLOPPY_OLD		2
+#define MAC_FLOPPY_IIFX		3
+#define MAC_FLOPPY_LC		4
 
 extern struct mac_model *macintosh_config;
 
arch/m68k/mac/config.c +65 -59

461 lines not on this page · raw message

Signature · 1 line
2.16.1
author
#6 lore raw

PATCH 3/12 m68k/mac: Don't remap SWIM MMIO region

In reply to Finn Thain

For reasons I don't understand, calling ioremap() then iounmap() on the SWIM MMIO region causes a hang on 68030 (but not on 68040).

~# modprobe swim_mod
SWIM floppy driver Version 0.2 (2008-10-30)
SWIM device not found !

watchdog: BUG: soft lockup - CPU#0 stuck for 23s! [modprobe:285]
Modules linked in: swim_mod(+)
Format 00  Vector: 0064  PC: 000075aa  Status: 2000    Not tainted
ORIG_D0: ffffffff  D0: d00c0000  A2: 007c2370  A1: 003f810c
A0: 00040000  D5: d0096800  D4: d0097e00
D3: 00000001  D2: 00000003  D1: 00000000
Non-Maskable Interrupt
Modules linked in: swim_mod(+)
PC: [<000075ba>] __iounmap+0x24/0x10e
SR: 2000  SP: 007abc48  a2: 007c2370
d0: d00c0000    d1: 000001a0    d2: 00000019    d3: 00000001
d4: d0097e00    d5: d0096800    a0: 00040000    a1: 003f810c
Process modprobe (pid: 285, task=007c2370)
Frame format=0
Stack from 007abc7c:
        ffffffed 00000000 006a4060 004712e0 007abca0 000076ea d0080000 00080000
        010bb4b8 007abcd8 010ba542 d0096000 00000000 00000000 00000001 010bb59c
        00000000 007abf30 010bb4b8 0047760a 0047763c 00477612 00616540 007abcec
        0020a91a 00477600 0047760a 010bb4cc 007abd18 002092f2 0047760a 00333b06
        007abd5c 00000000 0047760a 010bb4cc 00404f90 004776b8 00000001 007abd38
        00209446 010bb4cc 0047760a 010bb4cc 0020938e 0031f8be 00616540 007abd64
Call Trace: [<000076ea>] iounmap+0x46/0x5a
 [<00080000>] shrink_page_list+0x7f6/0xe06
 [<010ba542>] swim_probe+0xe4/0x496 [swim_mod]
 [<0020a91a>] platform_drv_probe+0x20/0x5e
 [<002092f2>] driver_probe_device+0x21c/0x2b8
 [<00333b06>] mutex_lock+0x0/0x2e
 [<00209446>] __driver_attach+0xb8/0xce
 [<0020938e>] __driver_attach+0x0/0xce
 [<0031f8be>] klist_next+0x0/0xa0
 [<00207562>] bus_for_each_dev+0x74/0xba
 [<000344c0>] blocking_notifier_call_chain+0x0/0x20
 [<00333b06>] mutex_lock+0x0/0x2e
 [<00208e44>] driver_attach+0x1a/0x1e
 [<0020938e>] __driver_attach+0x0/0xce
 [<00207e26>] bus_add_driver+0x188/0x234
 [<000344c0>] blocking_notifier_call_chain+0x0/0x20
 [<00209894>] driver_register+0x58/0x104
 [<000344c0>] blocking_notifier_call_chain+0x0/0x20
 [<010bd000>] swim_init+0x0/0x2c [swim_mod]
 [<0020a7be>] __platform_driver_register+0x38/0x3c
 [<010bd028>] swim_init+0x28/0x2c [swim_mod]
 [<000020dc>] do_one_initcall+0x38/0x196
 [<000344c0>] blocking_notifier_call_chain+0x0/0x20
 [<003331cc>] mutex_unlock+0x0/0x3e
 [<00333b06>] mutex_lock+0x0/0x2e
 [<003331cc>] mutex_unlock+0x0/0x3e
 [<00333b06>] mutex_lock+0x0/0x2e
 [<003331cc>] mutex_unlock+0x0/0x3e
 [<00333b06>] mutex_lock+0x0/0x2e
 [<003331cc>] mutex_unlock+0x0/0x3e
 [<00333b06>] mutex_lock+0x0/0x2e
 [<00075008>] __free_pages+0x0/0x38
 [<000045c0>] mangle_kernel_stack+0x30/0xda
 [<000344c0>] blocking_notifier_call_chain+0x0/0x20
 [<003331cc>] mutex_unlock+0x0/0x3e
 [<00333b06>] mutex_lock+0x0/0x2e
 [<0005ced4>] do_init_module+0x42/0x266
 [<010bd000>] swim_init+0x0/0x2c [swim_mod]
 [<000344c0>] blocking_notifier_call_chain+0x0/0x20
 [<0005eda0>] load_module+0x1a30/0x1e70
 [<0000465d>] mangle_kernel_stack+0xcd/0xda
 [<00331c64>] __generic_copy_from_user+0x0/0x46
 [<0033256e>] _cond_resched+0x0/0x32
 [<00331b9c>] memset+0x0/0x98
 [<0033256e>] _cond_resched+0x0/0x32
 [<0005f25c>] SyS_init_module+0x7c/0x112
 [<00002000>] _start+0x0/0x8
 [<00002000>] _start+0x0/0x8
 [<00331c82>] __generic_copy_from_user+0x1e/0x46
 [<0005f2b2>] SyS_init_module+0xd2/0x112
 [<0000465d>] mangle_kernel_stack+0xcd/0xda
 [<00002b40>] syscall+0x8/0xc
 [<0000465d>] mangle_kernel_stack+0xcd/0xda
 [<0008c00c>] pcpu_balance_workfn+0xb2/0x40e
Code: 2200 7419 e4a9 e589 2841 d9fc 0000 1000 <2414> 7203 c282 7602 b681 6600 0096 0242 fe00 0482 0000 0000 e9c0 11c3 ed89 2642

There's no need to call ioremap() for the SWIM address range, as it lies within the usual IO device region at 0x5000 0000, which is already mapped.

Remove the redundant ioremap() and iounmap() calls to fix the hang.

---
 drivers/block/swim.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/block/swim.c +3 -7
index 84434d3ea19b..ef4361dc5b26 100644
@@ -911,7 +911,7 @@ static int swim_probe(struct platform_device *dev)
 		goto out;
 	}
 
-	swim_base = ioremap(res->start, resource_size(res));
+	swim_base = (struct swim __iomem *)res->start;
 	if (!swim_base) {
 		ret = -ENOMEM;
 		goto out_release_io;
@@ -923,7 +923,7 @@ static int swim_probe(struct platform_device *dev)
 	if (!get_swim_mode(swim_base)) {
 		printk(KERN_INFO "SWIM device not found !\n");
 		ret = -ENODEV;
-		goto out_iounmap;
+		goto out_release_io;
 	}
 
 	/* set platform driver data */
@@ -931,7 +931,7 @@ static int swim_probe(struct platform_device *dev)
 	swd = kzalloc(sizeof(struct swim_priv), GFP_KERNEL);
 	if (!swd) {
 		ret = -ENOMEM;
-		goto out_iounmap;
+		goto out_release_io;
 	}
 	platform_set_drvdata(dev, swd);
 
@@ -945,8 +945,6 @@ static int swim_probe(struct platform_device *dev)
 
 out_kfree:
 	kfree(swd);
-out_iounmap:
-	iounmap(swim_base);
 out_release_io:
 	release_mem_region(res->start, resource_size(res));
 out:
@@ -974,8 +972,6 @@ static int swim_remove(struct platform_device *dev)
 	for (drive = 0; drive < swd->floppy_count; drive++)
 		floppy_eject(&swd->unit[drive]);
 
-	iounmap(swd->base);
-
 	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	if (res)
 		release_mem_region(res->start, resource_size(res));
Signature · 1 line
2.16.1
Acked-by on the v1 series
#34 lore raw
In reply to Finn Thain
Quoted 32 lines · Finn Thain

This patch series has fixes for bugs in the SWIM floppy disk controller driver, including an oops and a soft lockup.

There are also patches to add support for SWIM devices connected to IOPs.

Geert, would you please take this series through the m68k tree once the necessary "acked-by" tags arrive?

Jens, I've Cc'd you too because there's no official maintainer for drivers/block/swim.c and none for the drivers/block/ directory either.

The series could be separated into m68k patches and block driver patches and sent through different trees if that's preferred.

I did not do so because "acked-by" tags would still be needed and because separating patches 4 and 5 didn't make much sense.

Finn Thain (12):
m68k/mac: Revisit floppy disc controller base addresses m68k/mac: Fix SWIM memory resource end address m68k/mac: Don't remap SWIM MMIO region
m68k/mac: Place ISM IOP in bypass mode
block/swim: Use HEDSEL bit in ISM mode register block/swim: Fix array bounds check
block/swim: Remove extra put_disk() call from error path block/swim: Don't log an error message for an invalid ioctl block/swim: Rename macros to avoid inconsistent inverted logic block/swim: Check drive type
block/swim: Fix IO error at end of medium block/swim: Select appropriate drive on device open

Quoted 7 lines
 arch/m68k/include/asm/macintosh.h |  10 +--
 arch/m68k/mac/config.c            | 126 ++++++++++++++++++++------------------
 arch/m68k/mac/iop.c               |   8 ++-
 drivers/block/swim.c              |  69 +++++++++++----------
 drivers/block/swim3.c             |   6 +-
 5 files changed, 118 insertions(+), 101 deletions(-)

FWIW, for the series:

Thanks,
Laurent

maintainer
#36 lore raw
In reply to Finn Thain
Quoted 10 lines · Finn Thain

This patch series has fixes for bugs in the SWIM floppy disk controller driver, including an oops and a soft lockup.

There are also patches to add support for SWIM devices connected to IOPs.

Geert, would you please take this series through the m68k tree once the necessary "acked-by" tags arrive?

Jens, I've Cc'd you too because there's no official maintainer for drivers/block/swim.c and none for the drivers/block/ directory either.

The latter should just be added to the BLOCK LAYER entry.

Quoted 2 lines

The series could be separated into m68k patches and block driver patches and sent through different trees if that's preferred.

I can take the block bits.

Signature · 1 line
Jens Axboe
maintainer
#37 lore raw
Quoted 6 lines · Jens Axboe
Quoted 5 lines · Finn Thain

This patch series has fixes for bugs in the SWIM floppy disk controller driver, including an oops and a soft lockup.

There are also patches to add support for SWIM devices connected to IOPs.

Quoted 7 lines
Quoted 5 lines

Geert, would you please take this series through the m68k tree once the necessary "acked-by" tags arrive?

Jens, I've Cc'd you too because there's no official maintainer for drivers/block/swim.c and none for the drivers/block/ directory either.

The latter should just be added to the BLOCK LAYER entry.

Actually, when Linus takes the pull request, it will be there:

commit fc9de9a52e993829d928825d05fc9d3f41ce33fa

Author: Ross Zwisler <[email protected]>
Date:   Fri Mar 9 09:38:26 2018 -0700

MAINTAINERS: add coverage for drivers/block

Signature · 1 line
Jens Axboe
#13 lore raw

Re: [PATCH 04/12] m68k/mac: Place ISM IOP in bypass mode

In reply to Finn Thain

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 21.9936)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Build OK!
v4.4.126: Build OK!

Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks.
Sasha

#15 lore raw

Re: [PATCH 05/12] block/swim: Use HEDSEL bit in ISM mode register

In reply to Finn Thain

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 10.3364)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Build OK!
v4.4.126: Build OK!

Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks.
Sasha

#17 lore raw

Re: [PATCH 06/12] block/swim: Fix array bounds check

In reply to Finn Thain

Hi Finn Thain.

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag. fixing commit: 8852ecd97488 m68k: mac - Add SWIM floppy support.

The bot has also determined it's probably a bug fixing patch. (score: 56.6352)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Build OK!
v4.4.126: Build OK!

--
Thanks.
Sasha

#29 lore raw

Re: [PATCH 10/12] block/swim: Check drive type

In reply to Finn Thain

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 7.1126)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Build failed! Errors:
drivers/block/swim.c:838:26: error: ‘ONEMEG_DRIVE’ undeclared (first use in this function); did you mean ‘TWOMEG_DRIVE’?

v4.14.32: Build failed! Errors:
drivers/block/swim.c:838:26: error: ‘ONEMEG_DRIVE’ undeclared (first use in this function); did you mean ‘TWOMEG_DRIVE’?

v4.9.92: Build failed! Errors:
drivers/block/swim.c:822:26: error: ‘ONEMEG_DRIVE’ undeclared (first use in this function); did you mean ‘TWOMEG_DRIVE’?

v4.4.126: Build failed! Errors:
drivers/block/swim.c:822:26: error: ‘ONEMEG_DRIVE’ undeclared (first use in this function); did you mean ‘TWOMEG_DRIVE’?

Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks.
Sasha

#4 lore raw

Re: [PATCH 02/12] m68k/mac: Fix SWIM memory resource end address

In reply to Finn Thain

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 10.3464)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Failed to apply! Possible dependencies:

    a9373f40ac3a: ("m68k/mac: Adopt platform_device_register_simple()")

v4.4.126: Failed to apply! Possible dependencies:

    a9373f40ac3a: ("m68k/mac: Adopt platform_device_register_simple()")

Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks.
Sasha

#33 lore raw

Re: [PATCH 12/12] block/swim: Select appropriate drive on device open

In reply to Finn Thain

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 3.6525)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Build OK!
v4.4.126: Build OK!

Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks.
Sasha

#31 lore raw

Re: [PATCH 11/12] block/swim: Fix IO error at end of medium

In reply to Finn Thain

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 30.0899)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Failed to apply! Possible dependencies:
1eaee38a196c: ("block/swim: Rename macros to avoid inconsistent inverted logic")

v4.14.32: Failed to apply! Possible dependencies:
1eaee38a196c: ("block/swim: Rename macros to avoid inconsistent inverted logic")

v4.9.92: Failed to apply! Possible dependencies:
1eaee38a196c: ("block/swim: Rename macros to avoid inconsistent inverted logic")

v4.4.126: Failed to apply! Possible dependencies:
1eaee38a196c: ("block/swim: Rename macros to avoid inconsistent inverted logic")

Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks.
Sasha

#38 lore raw
In reply to Finn Thain

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 3.6525)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Build OK!
v4.4.126: Build OK!

Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks.
Sasha

#21 lore raw

Re: [PATCH 07/12] block/swim: Remove extra put_disk() call from error path

In reply to Finn Thain

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 1.4859)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Failed to apply! Possible dependencies:
103db8b2dfa5: ("swim: stop sharing request queue across multiple gendisks")

v4.4.126: Failed to apply! Possible dependencies:
103db8b2dfa5: ("swim: stop sharing request queue across multiple gendisks")

Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks.
Sasha

#24 lore raw

Re: [PATCH 08/12] block/swim: Don't log an error message for an invalid ioctl

In reply to Finn Thain

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 3.2953)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Build OK!
v4.4.126: Build OK!

Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks.
Sasha

#7 lore raw

Re: [PATCH 03/12] m68k/mac: Don't remap SWIM MMIO region

In reply to Finn Thain

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 30.4620)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Build OK!
v4.4.126: Build OK!

Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks.
Sasha

#2 lore raw

Re: [PATCH 01/12] m68k/mac: Revisit floppy disc controller base addresses

In reply to Finn Thain

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 17.4954)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Failed to apply! Possible dependencies:
b87eaec27eca: ("nubus: Add expansion_type values for various Mac models")

v4.14.32: Failed to apply! Possible dependencies:
b87eaec27eca: ("nubus: Add expansion_type values for various Mac models")

v4.9.92: Failed to apply! Possible dependencies:
b87eaec27eca: ("nubus: Add expansion_type values for various Mac models")
a9373f40ac3a: ("m68k/mac: Adopt platform_device_register_simple()")

v4.4.126: Failed to apply! Possible dependencies:
b87eaec27eca: ("nubus: Add expansion_type values for various Mac models")
a9373f40ac3a: ("m68k/mac: Adopt platform_device_register_simple()")

Please let us know if you'd like to have this patch included in a stable tree.

--
Thanks.
Sasha

maintainer
#39 lore raw
In reply to Sasha Levin
Quoted 7 lines · Sasha Levin

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 3.6525)

Quoted 8 lines

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Build OK!
v4.4.126: Build OK!

Please let us know if you'd like to have this patch included in a stable tree.

Did this bot respond to the whole series here, or the 00/12 patch? :)

thanks,

greg k-h

#40 lore raw
Quoted 10 lines · Greg KH
Quoted 9 lines · Sasha Levin

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 3.6525)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

Quoted 8 lines
Quoted 6 lines

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Build OK!
v4.4.126: Build OK!

Please let us know if you'd like to have this patch included in a stable tree.

Did this bot respond to the whole series here, or the 00/12 patch? :)

I'm experimenting with an idea that involves squashing a series of commits into a single commit and running it through the NN that way.

I figured it might make sense since when people mail patches this way there's usually dependencies between them, so if a random patch in the series got tagged for stable, we'll need to bring in the rest of the series as well.

So yes, in this case the entire series was identified by the NN as stable material. You can also see that there are separate mails for individual patches in the series - they acts as a sort of a fallback saying "maybe you don't want the whole series, but consider these as individual patches" (also gives a hint as to why the entire series was selected).

Quoted 3 lines

thanks,

greg k-h

maintainer
#41 lore raw
Quoted 28 lines · Sasha Levin
Quoted 10 lines · Greg KH
Quoted 9 lines · Sasha Levin

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 3.6525)

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

Quoted 8 lines
Quoted 6 lines

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Build OK!
v4.4.126: Build OK!

Please let us know if you'd like to have this patch included in a stable tree.

Did this bot respond to the whole series here, or the 00/12 patch? :)

I'm experimenting with an idea that involves squashing a series of commits into a single commit and running it through the NN that way.

I figured it might make sense since when people mail patches this way there's usually dependencies between them, so if a random patch in the series got tagged for stable, we'll need to bring in the rest of the series as well.

Quoted 6 lines

So yes, in this case the entire series was identified by the NN as stable material. You can also see that there are separate mails for individual patches in the series - they acts as a sort of a fallback saying "maybe you don't want the whole series, but consider these as individual patches" (also gives a hint as to why the entire series was selected).

Ah, very nice stuff! Thanks for the explaination.

greg k-h

author
#42 lore raw
In reply to Sasha Levin
Quoted 7 lines · Sasha Levin

Hi Finn Thain.

[This is an automated email]

This commit has been processed by the -stable helper bot and determined to be a high probability candidate for -stable trees. (score: 3.6525)

Quoted 9 lines

The bot has tested the following trees: v4.15.15, v4.14.32, v4.9.92, v4.4.126,

v4.15.15: Build OK!
v4.14.32: Build OK!
v4.9.92: Build OK!
v4.4.126: Build OK!

Please let us know if you'd like to have this patch included in a stable tree.

Thanks for your offer.

If this entire series goes upstream, it would be great to have it backported to 4.14 and 4.15.

But you'd need to cherry-pick commit b87eaec27eca3def6c8ed617e3b1bac08d7bc715 first (but I guess your build bot already did that).

Quoted 3 lines

--
Thanks.
Sasha

maintainer Reviewed-by on v1 2/12
#5 lore raw

Re: [PATCH 02/12] m68k/mac: Fix SWIM memory resource end address

In reply to Finn Thain
Quoted 6 lines · Finn Thain

The resource size is 0x2000 == end - start + 1. Therefore end == start + 0x2000 - 1.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#8 lore raw

Re: [PATCH 03/12] m68k/mac: Don't remap SWIM MMIO region

In reply to Finn Thain

Hi Finn,

Quoted 2 lines · Finn Thain

For reasons I don't understand, calling ioremap() then iounmap() on the SWIM MMIO region causes a hang on 68030 (but not on 68040).

Michael Schmitz also notices strange things with ioremap() on '030.

Quoted 2 lines

There's no need to call ioremap() for the SWIM address range, as it lies within the usual IO device region at 0x5000 0000, which is already mapped.

by head.S, right?

drivers/block/swim.c static int swim_probe(struct platform_device *dev) · line 914

Quoted 8 lines
drivers/block/swim.c +1 -1
@@ -911,7 +911,7 @@ static int swim_probe(struct platform_device *dev)
                goto out;
        }
 
-       swim_base = ioremap(res->start, resource_size(res));
+       swim_base = (struct swim __iomem *)res->start;

I guess you need a __force to please sparse?

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer Reviewed-by on v1 6/12
#18 lore raw

Re: [PATCH 06/12] block/swim: Fix array bounds check

In reply to Finn Thain

Hi Finn,

Quoted 6 lines · Finn Thain

In the floppy_find() function in swim.c is a call to get_disk(swd->unit[drive].disk). The actual parameter to this call can be a NULL pointer when drive == swd->floppy_count. This causes an oops in get_disk().

Data read fault at 0x00000198 in Super Data (pc=0x1be5b6)

[...]

Quoted 7 lines

Fix the array index bounds check to avoid this.

Fixes 8852ecd97488 ("[PATCH] m68k: mac - Add SWIM floppy support")
Cc Laurent Vivier <[email protected]>
Cc Jens Axboe <[email protected]>

Looks like amiflop.c:find_floppy() needs a check, too?

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer Reviewed-by on v1 7/12
#22 lore raw

Re: [PATCH 07/12] block/swim: Remove extra put_disk() call from error path

In reply to Finn Thain
Quoted 4 lines · Finn Thain

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
maintainer Reviewed-by on v1 8/12
#25 lore raw

Re: [PATCH 08/12] block/swim: Don't log an error message for an invalid ioctl

In reply to Finn Thain
Quoted 8 lines · Finn Thain

The 'eject' shell command may send various different ioctl commands. This leads to error messages on the console even though the FDEJECT ioctl succeeds.

~# eject floppy
SWIM floppy_ioctl: unknown cmd 21257
SWIM floppy_ioctl: unknown cmd 1

Quoted 7 lines

Don't log an error message for an invalid ioctl, just do as the swim3 driver does and return -ENOTTY.

Looks like amiflop can use a similar fix.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#9 lore raw

Re: [PATCH 03/12] m68k/mac: Don't remap SWIM MMIO region

In reply to Geert Uytterhoeven
Quoted 5 lines · Geert Uytterhoeven

drivers/block/swim.c static int swim_probe(struct platform_device *dev) · line 914

Quoted 3 lines
drivers/block/swim.c +1 -1
-       swim_base = ioremap(res->start, resource_size(res));
+       swim_base = (struct swim __iomem *)res->start;

I guess you need a __force to please sparse?

Hi,

Only pointer-to-pointer conversions may need __force. The logic being if you use an integer type to hold an address this address is typeless anyway and has no address-space, so extra checking is not done in this case and the cast in itself is enough.

Cheers,
-- Luc

author
#19 lore raw

Re: [PATCH 06/12] block/swim: Fix array bounds check

In reply to Geert Uytterhoeven
Quoted 2 lines · Geert Uytterhoeven

Looks like amiflop.c:find_floppy() needs a check, too?

AFAICS there is no array index bug in floppy_find() in amiflop.c. The 'unit' array's size is FD_MAX_UNITS which is defined as 4 in include/linux/amifd.h, and the array index is drive = *part & 3.

author
#26 lore raw

Re: [PATCH 08/12] block/swim: Don't log an error message for an invalid ioctl

In reply to Geert Uytterhoeven
Quoted 12 lines · Geert Uytterhoeven
Quoted 11 lines · Finn Thain

The 'eject' shell command may send various different ioctl commands. This leads to error messages on the console even though the FDEJECT ioctl succeeds.

~# eject floppy
SWIM floppy_ioctl: unknown cmd 21257
SWIM floppy_ioctl: unknown cmd 1

Don't log an error message for an invalid ioctl, just do as the swim3 driver does and return -ENOTTY.

Quoted 9 lines
Quoted 4 lines

Looks like amiflop can use a similar fix.

Right. I'll prepare a new patch for that and send it separately.

Quoted 5 lines

Gr{oetje,eeting}s,

Geert

author
#10 lore raw

Re: [PATCH 03/12] m68k/mac: Don't remap SWIM MMIO region

In reply to Geert Uytterhoeven
Quoted 7 lines · Geert Uytterhoeven

Hi Finn,

Quoted 2 lines · Finn Thain

For reasons I don't understand, calling ioremap() then iounmap() on the SWIM MMIO region causes a hang on 68030 (but not on 68040).

Quoted 8 lines

Michael Schmitz also notices strange things with ioremap() on '030.

Quoted 3 lines

There's no need to call ioremap() for the SWIM address range, as it lies within the usual IO device region at 0x5000 0000, which is already mapped.

by head.S, right?

Right. I'll mention that in the commit log when I re-submit this series.

Quoted 11 lines

drivers/block/swim.c static int swim_probe(struct platform_device *dev) · line 914

Quoted 8 lines
drivers/block/swim.c +1 -1
@@ -911,7 +911,7 @@ static int swim_probe(struct platform_device *dev)
                goto out;
        }
 
-       swim_base = ioremap(res->start, resource_size(res));
+       swim_base = (struct swim __iomem *)res->start;

I guess you need a __force to please sparse?

No, sparse did not find any new issues. It appears there's an old issue elsewhere in the driver though. I'll prepare a new patch for that.

Quoted 5 lines

Gr{oetje,eeting}s,

Geert

#11 lore raw

Re: [PATCH 03/12] m68k/mac: Don't remap SWIM MMIO region

In reply to Geert Uytterhoeven

Hi Geert,

I haven't seen that weird behaviour in quite some time - we discussed changing the arch_initcall to some later priority at that time but I never got around to trying that. No change to mappings in head.S either as far as I could see.

Was there any rearrangement of MM init relative to arch init since?

Cheers,

Michael

Quoted 38 lines · Geert Uytterhoeven

Hi Finn,

Quoted 2 lines · Finn Thain

For reasons I don't understand, calling ioremap() then iounmap() on the SWIM MMIO region causes a hang on 68030 (but not on 68040).

Michael Schmitz also notices strange things with ioremap() on '030.

Quoted 2 lines

There's no need to call ioremap() for the SWIM address range, as it lies within the usual IO device region at 0x5000 0000, which is already mapped.

by head.S, right?

drivers/block/swim.c static int swim_probe(struct platform_device *dev) · line 914

Quoted 8 lines
drivers/block/swim.c +1 -1
@@ -911,7 +911,7 @@ static int swim_probe(struct platform_device *dev)
                goto out;
        }
 
-       swim_base = ioremap(res->start, resource_size(res));
+       swim_base = (struct swim __iomem *)res->start;

I guess you need a __force to please sparse?

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html