Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795055269; b=xzfawuz0YQsSeyLLzAwp3DoWYM9pMZT+Pu9GMRchLKjiCnZ5bryuy8uXsgYQgTxLERDX mE3ofX5IeN4UQ6I+/YcuB31l2DqM+5EzTWdPkvBNii4zVpA+PW4Hzz++fGtA4PjFwz5e/ oACHANA9NRsBO/6Gyd/LNFGAIJvDM8m84W3ATnvT/i/WgsNO/LAZ8dF3hHpUVZ/aveUPy B9O49Dy03ucYTYhQpqOMOq88VG8aRGVhMTIoG10pvPYIUBbPZBKdG4NgTMpT5mSH/Ww85 RsGeZ37aMOfBPHB36/EPg8lUfFgmL57JuR6Kzu4U+PSI3vMmGe66/847/Cd4HRHypnw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795055269; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=wi5GIu1bdb1gMqKPk8H2J94DuBdFBYsl0YRK30uTSHQ=; b=Y1nt39GGL1BGWy09XIPu2bNMhpElFQlujX9GJh0Ujl1I9kxPuE+sSUm/49RUF7Ymu0Rj BJemJM1FH7TWB7sxsOLFr2CXOZi+D6juOsS/RzpNvhCf+vO4smHhJlZZ1R9oAexyMOpoa Ie4lQKxdC+gsyKFYqEV9/pXvPNHi2C6UecafMFyhAo/uHD7y6ViqVcAeTAYUD1Mas8OVY DsyXdBP82Zm7edEt+JCWKpKiKfrW0n/5kUyszQMs8vGDcRLt72SJW4JbczfDZUsJRRRS/ 0KUyvWVkeitKHwEAJxzLxNaadD1IPjUjEncLglOT5o8vaGESDWyTA8IJqPMLGQHhBDg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=JGiwnIyM; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAF2A606A337; Thu, 19 Nov 2026 02:27:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=JGiwnIyM Received: by smtp.kernel.org (Postfix) with ESMTPSA id C40551F000C4; Thu, 19 Nov 2026 02:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795055269; bh=wi5GIu1bdb1gMqKPk8H2J94DuBdFBYsl0YRK30uTSHQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JGiwnIyMYpCD5zGUf9J3gE5ynYnyqfOPXKc+Mygj0Ax1UfW6MK9b6XJB1z45aGFvx YoHernFgsD96OoFWNXcbA9G0C1Brq7t34cvCC8odVcaQMGf2yubxFSruu/lZKMra8V VNCIHacWQWKkct2ab4KjX0x/H1ZDHfM2SB+8bk6U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Finn Thain , Stan Johnson , Jens Axboe , Sasha Levin Subject: [PATCH 5.15 1571/2214] swim: Recalibrate when drive is probed Date: Wed, 18 Nov 2026 15:54:07 +0100 Message-ID: <20261118150114.900397868@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150009.797899913@linuxfoundation.org> References: <20261118150009.797899913@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Finn Thain [ Upstream commit ba087774a1493ade524f8a783461fa8be9c75039 ] Track zero recalibration can be slow and is normally done only once i.e. during system POST or boot-up. Recalibrate once after the drive is probed rather than every time the device is opened. Don't register the drive if recalibration fails. Park the heads before ejecting. Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson Link: https://patch.msgid.link/119e799afcc00d6bd4a479c31e0c960cb1a1d71b.1788513997.git.fthain@linux-m68k.org Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/swim.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index ec2191ddda847..6fdfcfc5f05ef 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -411,6 +411,7 @@ static inline int swim_track00(struct swim __iomem *base) if (swim_readbit(base, TRACK_ZERO)) return 0; + pr_err("swim: track zero recalibration failed\n"); return -1; } @@ -455,6 +456,7 @@ static int floppy_eject(struct floppy_state *fs) struct swim __iomem *base = fs->swd->base; swim_drive(base, fs->location); + swim_track(fs, 40); swim_motor(base, OFF); swim_eject(base); swim_drive(base, NO_DRIVE); @@ -595,13 +597,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); - - if (swim_track00(base)) - printk(KERN_ERR - "SWIM: cannot move floppy head to track 0\n"); - - swim_track00(base); - fs->type = swim_readbit(base, TWOMEG_MEDIA) ? HD_MEDIA : DD_MEDIA; fs->head_number = swim_readbit(base, SINGLE_SIDED) ? 1 : 2; @@ -609,7 +604,6 @@ static void setup_medium(struct floppy_state *fs) fs->total_secs = g->size; fs->secpercyl = g->head * g->sect; fs->secpertrack = g->sect; - fs->track = 0; } else { fs->disk_in = 0; } @@ -761,24 +755,33 @@ static const struct block_device_operations floppy_fops = { .check_events = floppy_check_events, }; -static int swim_add_floppy(struct swim_priv *swd, enum drive_location location) +static void swim_add_floppy(struct swim_priv *swd, enum drive_location location) { struct floppy_state *fs = &swd->unit[swd->floppy_count]; struct swim __iomem *base = swd->base; - fs->location = location; + swim_drive(base, location); + if (!swim_readbit(base, DRIVE_PRESENT) || + swim_readbit(base, ONEMEG_DRIVE)) + goto out; + if (swim_readbit(base, DISK_IN)) + swim_motor(base, ON); + if (swim_track00(base)) + goto out; - swim_motor(base, OFF); + fs->location = location; fs->type = HD_MEDIA; fs->head_number = 2; fs->ref_count = 0; fs->ejected = 1; + fs->track = 0; swd->floppy_count++; - return 0; +out: + swim_motor(base, OFF); } static const struct blk_mq_ops swim_mq_ops = { @@ -817,14 +820,8 @@ static int swim_floppy_init(struct swim_priv *swd) /* scan floppy drives */ - swim_drive(base, INTERNAL_DRIVE); - 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) && - !swim_readbit(base, ONEMEG_DRIVE)) - swim_add_floppy(swd, EXTERNAL_DRIVE); + swim_add_floppy(swd, INTERNAL_DRIVE); + swim_add_floppy(swd, EXTERNAL_DRIVE); swim_drive(base, NO_DRIVE); /* register floppy drives */ -- 2.53.0