From mboxrd@z Thu Jan 1 00:00:00 1970 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=1795024196; b=TiltYM3z6C74DPz9WkP9/hKzTp+7qX22+F2BDpNKURonRGH0Z3N5nO+TbQp2iydMZj9c PzEK9cYsPAHK9UT2O9WEOeFGhVe9PgZA0uV6XgVBZ7zbumsNi6bAHGoMTBUulz6q7vElO 3PCv0hhO+vY3hMYvZNMjvPZmV01QpL2U/uo9QOim7ezulS51HV0cU3u1fBNJ09fLEyudK ioA6v2sHTFJfyWXOpByM9mX0nofo5QgikN/EnHpcYs9EFJJ/s3Rz0N7xNNPymhfCyZbPS jy+csCWwXMYHBq4jfupAW30E2EqFPtcvpuovSAPKlHuUNAUN05RBA/Ze1cjLEV11NVg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795024196; 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=97yW4LnbToVt4kBEqJyZ+j4PbAgFf7aFdy48CmeXd4I=; b=aDYitkBU4U2f9kgseweuaXdViy7uNS1GquXk8GVzWM7QE02PWmkWsr4cah3wVG21iQtD uJaaGLiYuRLvbK9DV2yulMub6CRHlSzfVUp3FMISbUVdu55IjOx1090EsGYoTHkDLxmpO D+qKJBNESCAi0PfeY6uZ+l3XOXlzoNPYJlEsKEXDMmke81VXdQezzV59Bfb3rM0XJQ6MI uopdbZc6I+6NuJalJPGyayXmhznMgdubtob9brYnSoeJbJkQDneuCnvpBsWshglNVIb4U r2bN/oCdAvBP6dRp44YMZdlnoXaaoCbGP6S3V9MMd8VfQVRSYCsnOgT6oBHzdbtIOwg== 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=QnHHgcVf; 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 8BDF9606A31C; Wed, 18 Nov 2026 17:49:56 +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=QnHHgcVf Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6EA41F000C4; Wed, 18 Nov 2026 17:49:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795024196; bh=97yW4LnbToVt4kBEqJyZ+j4PbAgFf7aFdy48CmeXd4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QnHHgcVfi3Th4dcRw24zV6vCuK9tsuO3RT2YAnHK7iaJXiIAzoFMH3vFKo52neZoD WrkOE+mTqB4zYcg7sennVNIy5b7WMfMdpM+nxLXjZFW88meUdnM64FD1sCBrvwEa4s GwrlyqqL0d11sfVIwWKu2kqIQp6eaKCf19WCv95k= 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 6.18 0638/2151] swim: Recalibrate when drive is probed Date: Wed, 18 Nov 2026 15:39:33 +0100 Message-ID: <20261118150145.118807410@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150121.603863898@linuxfoundation.org> References: <20261118150121.603863898@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 6.18-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 4b8d5268c900c..4915b5e1ceaec 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -412,6 +412,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; } @@ -456,6 +457,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); @@ -596,13 +598,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; @@ -610,7 +605,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; } @@ -759,24 +753,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 = { @@ -826,14 +829,8 @@ static int swim_floppy_init(struct platform_device *pdev) /* 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