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=1795029968; b=c8Ji6EJ59cOXoWUQ+vNCUc1c4C0ufBezsMJtomuD+n9LyJ66jNfYHCzjoqcYhCQsLeeZ VFDZnCis2vRwJWxCdJIU+JuliIKXn5rPX/v9365MO2eG6pnXaYuS0DBKy5b6hrM8SEvho 9okhUsZB/UhMtv9gZ6YmqKlVC9JKp+K6MX9UhkP9F29bGF0KzLhF6YxCqdE/NsjNfgeho RLaHWE1iNiU7HIYdQbgsgGXSZs/cVJ7hOZsLNVAUDImdXwwpwy1KHfVxv0bGidbJW47ZY r1XYL73UyuPsSAfa/dvou3sBd5KcJ62WSax3hxwEJ2nO842gtEKxl1LcVBxM32bck5Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795029968; 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=r2A8/Itphkp1Z2AeYZyzEOnxeikYK0ZUPVxriVk2rL0=; b=Iv8YvBpStd9o7sx1GYmfkUymg63VZ6mCSwfr3BtZueqZ6CBiZ00XUZFPvhXr5m6WPOwk bRGvj/uvkHADfZqiAwRq6YfKA1CUVpcJcqVfgZxGiZwufmrXI2cc97tspY5u4qnB602U9 FQ3/VGHIbYbvCoeS+yhjpCXvIhzb/jQ0NrLIlm0HMy/qCrXYc7LOLwPOv4M5rYALcvBpf 1B6L47Qs1eye3dUf/O1hRdZTjQK29vPo9RvV+l+YQCcbUw30mMAqrMEa02PBMI66gqGfT lpEITLyy4dAst6e20FCbdTR2cBsVlnWZVXYgN0fGE3NzPfSlmwu4Xy6UcwqhP4aCptw== 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=UPrDIy9B; 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 E2697606A320; Wed, 18 Nov 2026 19:26:07 +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=UPrDIy9B Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4597D1F000C4; Wed, 18 Nov 2026 19:26:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795029967; bh=r2A8/Itphkp1Z2AeYZyzEOnxeikYK0ZUPVxriVk2rL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UPrDIy9BVsLya5C5XvyeIMmFXTK2+HAGPjQL+25yGimHCZwMaGYLY3t4+AnOb2rES zMNetWv51QsiRu3EyfrIouXa8Ubowiqv3mpu3mSjlQ+Dp+bXBrqMmX1by2W9uN+yCB F/o+2r0AUwGB9lT9M/jLzLc0vk0AEziIbDJmYa0Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Laurent Vivier , Finn Thain , Stan Johnson , Jens Axboe , Sasha Levin Subject: [PATCH 6.12 0538/1756] swim: Check drive ready bit Date: Wed, 18 Nov 2026 15:44:25 +0100 Message-ID: <20261118150030.578695427@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150007.957976754@linuxfoundation.org> References: <20261118150007.957976754@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Finn Thain [ Upstream commit abae04f5bed924590e98fe1519566a6e0144e6b5 ] The drive provides a readiness signal that has to be tested before certain commands are issued to the drive. Rename the SEEK_COMPLETE flag as READY because that's how it's known in the documentation as well as the mkLinux source code. Poll for that signal after stepping the heads and also after switching to MFM mode, as that's what mkLinux does. Check for readiness when stepping because testing shows that some drives require this. Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson Link: https://patch.msgid.link/8d6fc833c719de2248b64ee521418b1032b1e509.1788513997.git.fthain@linux-m68k.org Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/swim.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index b4148dbe27142..1de2b9f7d40a1 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -117,7 +117,7 @@ struct iwm { #define TACHO 0x103 #define READ_DATA_1 0x104 #define GCR_MODE 0x105 -#define SEEK_COMPLETE 0x106 +#define READY 0x106 #define TWOMEG_MEDIA 0x107 /* Bits in handshake register */ @@ -313,6 +313,14 @@ static inline bool swim_readbit(struct swim __iomem *base, int bit) #define swim_readbit_timeout(base, bit, val, timeout_us) \ poll_timeout_us(, swim_readbit(base, bit) == val, 1000, timeout_us, false) +#define swim_READY_timeout(base) \ +({ \ + int ret = swim_readbit_timeout(base, READY, true, 1000 * 1000); \ + if (ret) \ + printk(KERN_DEBUG "%s: drive not ready\n", __func__); \ + ret; \ +}) + static inline void swim_drive(struct swim __iomem *base, enum drive_location location) { @@ -351,8 +359,6 @@ static inline void swim_eject(struct swim __iomem *base) static inline void swim_head(struct swim __iomem *base, enum head head) { - /* wait drive is ready */ - if (head == UPPER_HEAD) swim_select(base, READ_DATA_1); else if (head == LOWER_HEAD) @@ -387,20 +393,25 @@ static inline int swim_track00(struct swim __iomem *base) static inline int swim_seek(struct swim __iomem *base, int step) { - if (step == 0) - return 0; - if (step < 0) { swim_action(base, SEEK_NEGATIVE); step = -step; - } else + } else if (step > 0) swim_action(base, SEEK_POSITIVE); + swim_READY_timeout(base); + + if (step == 0) + return 0; + for ( ; step > 0; step--) { if (swim_step(base)) return -1; } + msleep(30); + swim_READY_timeout(base); + return 0; } @@ -482,6 +493,8 @@ static blk_status_t floppy_read_sectors(struct floppy_state *fs, swim_drive(base, fs->location); + swim_READY_timeout(base); + for (i = req_sector; i < req_sector + sectors_nb; i++) { int x; track = i / fs->secpercyl; @@ -602,6 +615,8 @@ static int floppy_open(struct gendisk *disk, blk_mode_t mode) swim_motor(base, ON); swim_action(base, SETMFM); + msleep(30); + swim_READY_timeout(base); set_capacity(fs->disk, fs->total_secs); -- 2.53.0