From nobody Sat Sep 26 05:27:39 2026 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17B70441623; Fri, 4 Sep 2026 09:31:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514297; cv=none; b=B8Ln3NUnSEbzAxXrolFo/nbvJqSYzehKJoYTxyxOTH54s4Fx2RwubWNsVZPji5kkoj+wSPoXU7dZCp3DmkR2WXy9eRUPju/jp9xlBJn2Dri/3ThhCue56yyzQ/0oVVd3Y21jGHTHog/vK+ebHhdN5ZtZxngkXvEtK3+DwLKENsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514297; c=relaxed/simple; bh=2s5056F3M1H1eGUdCR6jg3p7BkSWaD1ETpRDdlPRR3g=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=sxXEQb3RUonjUAfHVIF24IcM2ErG6cPiSy44EEOG/aIRKeDl2zaqFAErRUayBn+p08uN9tsT8X8Bm49o51EhdX0YeJlB7IMJoGvOnzcbs/DdUJ2Mjm0nDOiJH6nTEjPKPcnJInt81a4vTvAeMkKSizw6rtGb5464dpwOBPaUX6A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=RxUroyJj; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="RxUroyJj" Received: from phl-compute-08.internal (phl-compute-08.internal [10.202.2.48]) by mailfhigh.phl.internal (Postfix) with ESMTP id 3BE2B1400141; Fri, 4 Sep 2026 05:31:34 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Fri, 04 Sep 2026 05:31:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514294; x= 1788600694; bh=Jw4vsO0mgrk87gDApGL8bszTo0NjZbd8pbAFWOFBC2c=; b=R xUroyJj/18vTdGO/B+GHMHekHqld3EpcvsO8e8oCOE48PXegQKG5/TYM9Ikh9y/4 xFm0fukr13mAK0vUgDAJa3EueIlCsOZp92yRddpMc2KHUjpEMRhqMWwros5TSTPE yMrR2j4vvjrx33hVLbi8Yd+rMu2wulMZE8MbG33aq48AO0f4S94Ngx/3MnFLL+8i +xPnlu88VSrs6U+FKKqvPSvVKmfNAMxWnBCWy5uOCON7n/rLwsxvT9dy9cQjPprQ BiwEWNHOCgIL21ehahf06nzMmBjJD8hXCvZgdf+wnlvAFaaffk5UvSp0MMiWUbtu FfQTJMyk48zPATHwA0Ifg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEAKPWJVEMqJ16jAjOL9FB/rBffUzJbSVLQHlq9+RC52fsBvb13o/7yjvGYTuY3IH ZNCMm3A3s3Wzl4RLMlWp0jCSYNVS7BZQKRPO2yqi1PfebCSoLOeHqK6FATWT8bd3IKpoKZ CEwyBEjTXEy3FLlbxSNZDKwf3xO9EeiRAKVkzcAluKXcPMqMkrDpp1BPxnn7TPE8fvHu4l eJtWE0FI2UehL/YEbD5REmldbzGnWmAWgAUgfm0dSu3fH37RyKRhvYbjCw4HLJaLhP6501 B+Avisf8hlO2cQGDcAA1USTZdkjGliJjHtwHNkdXiWoCX0/+3sglem9KJOr2WDslSbN9Tk oaz6+XA7rykO29e6MB36RTFMNZLu1+r3NdU+EBC1l0HH/oxqcciuLWp0aJuMPMiCrODbO+ 9WqPwKorht9QVxKQkBnlD+Z1qLJEmWkGQCppFHS2YJ4Gq49lSCCKKRzIJb3ci3OZxBQVNQ rW2gEStcfzSv5K4noXlUuirbI3lOOsMk2G+5/b42IGJ7EfLkM0d+dPTNnGn7KsZDHbUrhB N2GsSYoYCeTFWXCVpE7Ot6Dc4vhxc3q8C5CBaWiCXkKRdt/6NDOmbM1WI1dC0TYM2ZJqul Dgfwef1KfH34zxHbTR6GaBgFh3DtqlKZgUYAAyj28e+ONRzfAVYfuMVz6F9A X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:31:32 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <6da86b9bfd1335fac3ebc8c435fb613d5de4a70c.1788513996.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 01/33] swim: Assert strobe with stable outputs Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Inside Macintosh says, "Be sure that you don't change CA0-CA2 or SEL while LSTRB is high". Unfortunately, those bits do change. The CA0-CA2 outputs become inputs when (LSTRB << 4) | LSTRB gets written to the phase register. Then LSTRB is driven low (with CA0-CA2 bits set). This is a problem because the drive interprets a STEP command as an EJECT command when these pins float high. This occurs intermittently, perhaps because interrupts are disabled and the race condition happens to end well. However, when I add code to step the heads with interrupts enabled, the disk always ejects. Keep the four phase pin directions set to output and hold their levels constant during LSTRB signalling. Introduce the PHASE_PIN_DIRECTION macro to separate the pin configuration from the logic level changes. Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson --- Changed since v1: - Added the PHASE_PIN_DIRECTION macro to improve readability. - Re-arranged macro definition groups so as to agree with their descriptions. Changed since v2: - Dropped reviewed-by tag due to unreviewed changes made since v1. --- drivers/block/swim.c | 62 ++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 0ccc12a72388..5d89e7813049 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -87,37 +87,37 @@ struct iwm { #define iwm_write(base, reg, v) out_8(&(base)->reg, (v)) #define iwm_read(base, reg) in_8(&(base)->reg) =20 -/* bits in phase register */ +/* Bits in phase register */ =20 -#define SEEK_POSITIVE 0x070 -#define SEEK_NEGATIVE 0x074 -#define STEP 0x071 -#define MOTOR_ON 0x072 -#define MOTOR_OFF 0x076 -#define INDEX 0x073 -#define EJECT 0x077 -#define SETMFM 0x171 -#define SETGCR 0x175 - -#define RELAX 0x033 -#define LSTRB 0x008 - -#define CA_MASK 0x077 +#define RELAX 0x03 +#define LSTRB 0x08 +#define CA_MASK 0x07 +#define PHASE_PIN_DIR 0xF0 =20 /* Select values for swim_select and swim_readbit */ =20 -#define READ_DATA_0 0x074 -#define ONEMEG_DRIVE 0x075 -#define SINGLE_SIDED 0x076 -#define DRIVE_PRESENT 0x077 -#define DISK_IN 0x170 -#define WRITE_PROT 0x171 -#define TRACK_ZERO 0x172 -#define TACHO 0x173 -#define READ_DATA_1 0x174 -#define GCR_MODE 0x175 -#define SEEK_COMPLETE 0x176 -#define TWOMEG_MEDIA 0x177 +#define SEEK_POSITIVE 0x000 +#define SEEK_NEGATIVE 0x004 +#define STEP 0x001 +#define MOTOR_ON 0x002 +#define MOTOR_OFF 0x006 +#define INDEX 0x003 +#define EJECT 0x007 +#define SETMFM 0x101 +#define SETGCR 0x105 + +#define READ_DATA_0 0x004 +#define ONEMEG_DRIVE 0x005 +#define SINGLE_SIDED 0x006 +#define DRIVE_PRESENT 0x007 +#define DISK_IN 0x100 +#define WRITE_PROT 0x101 +#define TRACK_ZERO 0x102 +#define TACHO 0x103 +#define READ_DATA_1 0x104 +#define GCR_MODE 0x105 +#define SEEK_COMPLETE 0x106 +#define TWOMEG_MEDIA 0x107 =20 /* Bits in handshake register */ =20 @@ -269,11 +269,11 @@ static inline int get_swim_mode(struct swim __iomem *= base) =20 static inline void swim_select(struct swim __iomem *base, int sel) { - swim_write(base, phase, RELAX); + swim_write(base, phase, RELAX | PHASE_PIN_DIR); =20 via1_set_head(sel & 0x100); =20 - swim_write(base, phase, sel & CA_MASK); + swim_write(base, phase, (sel & CA_MASK) | PHASE_PIN_DIR); } =20 static inline void swim_action(struct swim __iomem *base, int action) @@ -284,9 +284,9 @@ static inline void swim_action(struct swim __iomem *bas= e, int action) =20 swim_select(base, action); udelay(1); - swim_write(base, phase, (LSTRB<<4) | LSTRB); + swim_write(base, phase, LSTRB | action | PHASE_PIN_DIR); udelay(1); - swim_write(base, phase, (LSTRB<<4) | ((~LSTRB) & 0x0F)); + swim_write(base, phase, action | PHASE_PIN_DIR); udelay(1); =20 local_irq_restore(flags); --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07C9543FD0B; Fri, 4 Sep 2026 09:31:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514306; cv=none; b=dHFQkSqm228YRzOyxysp7fCS6iHt+ZxMUpcKMyKgbzCnio+ZLQY8N2TBbN0Ehbyp2QXnEHrmNgqpt+//twEfk6NKWbk3PdSn82fTcLuNvb7FCvJ1q3YcCeQMB1WQAIR5n1cyqCZ9FsLfP1+58vsQf/ofA92AzV1y7Wf+VMU28mk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514306; c=relaxed/simple; bh=zLTL0XSX377Q5uxNjt9iEMwwDbPUSFjdEiz/iPykOT4=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=KV+ESIqOalQO8tkr+uQ6B2m1AbA4zJLUeWpikzmd+mSRHIG7WUmMV5MjzOPUi9cylTp9cLmpSXjrdh29jvuStJDgVmha+VsgcLsmO5tBooVgRAJzqOuryMbBU1m+3ijV6QL2i85u1c6QIZ9K4+kG4R3VMGGsRb65YP8THsE8lrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=JM8p6LZe; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="JM8p6LZe" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id EB3D21400032; Fri, 4 Sep 2026 05:31:42 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Fri, 04 Sep 2026 05:31:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514302; x= 1788600702; bh=6enK1e/BFMkuBg8+irnlLj0CqFHztSRmCrF0cLMxqjM=; b=J M8p6LZe1YpTgYlrsryI1mg2tesLwa8dqyQdeyUovoE673BUHR8YEeivKcLtkiysr k2VLWd2hzbtb80eZXGwng42YKGZTLBpk2iOecccpwKJWqw8Whe5tJbOl38A+R0rd 0nUwodBUtvyRUYQszgm1ayvg+DUW702j2qKfv20P8/8F8to9I8FZdAsxlEPrBYNL hl50FQIBWqaannYFdCebgUeiRYRhaUbDwkvMLgR9eJzmP8Bvln8F7MOLmn1SE0bc vQck2fTnTCnkRzDHBJOpHs4CavJekHyZQA/5/vvfKjnOvuR24QmCVZ9qtJJCY7WX OwfEzqrANvn22iPeU01sg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEAKPWJVEMqJ16jAjOL9FB/rBffUzJbSVLQHlq9+RC52fsBvb13o/7yjvGYTuY3IH ZNCMm3A3s3Wzl4RLMlWp0jCSYNVS7BZQKRPO2yqi1PfebCSoLOeHqK6FATWT8bd3IKpoKZ CEwyBEjTXEy3FLlbxSNZDKwf3xO9EeiRAKVkzcAluKXcPMqMkrDpp1BPxnn7TPE8fvHu4l eJtWE0FI2UehL/YEbD5REmldbzGnWmAWgAUgfm0dSu3fH37RyKRhvYbjCw4HLJaLhP6501 B+Avisf8hlO2cQGDcAA1USTZdkjGliJjHtwHNkdXiWoCX0/+3sglem9KJOr2WDslSbN9I5 0PdLxvukadh6i2I3gYKXNv7IUbX6BNxZpHmSMD7c9cj8LUjNETU3CYGgAF/J4UVV6dMxuF NPnLK6Ty1cymiY7Q0u4mmW9Kf+3vrd1G/oLEe7QURr78z4cLt7dXc0lqGib3Sp+Kcg11c1 AbWe88+ExaurIfJicFrg+aWUlTF9szELhEp2fVGQ3+bCbjylHX5ooSrmBmDeCcnRkkSXCk HMQAyrlX/EEVccTPF6gaXCVaFc8QqKZgnKOqwR7Ow/RGau2wAYeTKEMTRgAVVkZCmhi/9W uJrwU8pGoc/+MaucrM+CH78ecivNEgAJY6B5QFHs6GZvbzQRtJ2L0BtEXd0g X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:31:41 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <370f73fcceb53ce4860904ce6cf4f06ade0e43d5.1788513996.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 02/33] swim: Select appropriate drive once only Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Before turning off the spindle motor, call swim_drive() to select the appropriate drive. Remove the swim_drive() call from swim_add_floppy() because it was already called by swim_floppy_init(). Reviewed-by: Laurent Vivier Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 5d89e7813049..4721e073a874 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -679,8 +679,10 @@ static void floppy_release(struct gendisk *disk) else if (fs->ref_count > 0) --fs->ref_count; =20 - if (fs->ref_count =3D=3D 0) + if (fs->ref_count =3D=3D 0) { + swim_drive(base, fs->location); swim_motor(base, OFF); + } mutex_unlock(&swim_mutex); } =20 @@ -752,8 +754,6 @@ static int swim_add_floppy(struct swim_priv *swd, enum = drive_location location) =20 fs->location =3D location; =20 - swim_drive(base, location); - swim_motor(base, OFF); =20 fs->type =3D HD_MEDIA; --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0AA073EC83E; Fri, 4 Sep 2026 09:31:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514314; cv=none; b=BPzqwsq/i+QEgisyiqwqUJ3JHZRRePEZt2A3Peyn2qajjEieApTgQ8TFaFALcDlAeB59GDN05fZ50d31VRJnNi1olS8+02EhYDbQCXZYdmk66X6Exdk1taeYVmvDFEADmvMJOoq+f01Emc8/Z4zpLSfSN3eBGX63GkAEajNoh18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514314; c=relaxed/simple; bh=TRCASMM7eelgWS4DcL5aA99Epa/8OLjxiXSiA4njPe0=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=E4VB3cNL5GQQQMoprRdG2Brtuz3maJHp3aPHTJDWMLqV+Gij6Spq32k88nARJuaRSR39bBDhhSPE2ANslkuK55+feGjoVbF62EgGwt7eOA95qPhH8A239gwYzg4fnNdhdoKfXvinADImfeM22lCkMhS0P9KfHd/wAxbDOEQFKaw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=MwRMd2ol; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="MwRMd2ol" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 2DE5CEC0110; Fri, 4 Sep 2026 05:31:52 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Fri, 04 Sep 2026 05:31:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514312; x= 1788600712; bh=RppOGoUsMSAGAcgwd3QV2Wk6AOZv4y+7OKDIjYynE4A=; b=M wRMd2olDQq3xL3gcG8KtxniYS4HI4e8Rr/mIV+mMkeamaUMa7ZKQZE/t48dWdEzV Q+bCMlYKZDpQWvWozNFOvSZfRUanLRrjqymkgJc65Y3xraedQVXHHKQqjcCWy5a2 Ah/2KQ1urHbEGQuLkz9UFwbFC/J8zBJpTVrmLp2tPTO8E1/d6X/IpH1peF9VAID2 WjyR59fC1njPMeGN66KX8DHI1g9gnB/2ZKPm1Gj3BbMQvByX0uUi8vFGKeQ63jgg oXVR8mvSchNlUaQo5fwKM8OpvhEliclg9H0467AfFmzVFsb+Px/uxY3rQTprgmKz 515+wgLaEFsXv0QxP9YDw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEAKPWJVEMqJ16jAjOL9FB/rBffUzJbSVLQHlq9+RC52fsBvb13o/7yjvGYTuY3IH ZNCMm3A3s3Wzl4RLMlWp0jCSYNVS7BZQKRPO2yqi1PfebCSoLOeHqK6FATWT8bd3IKpoKZ CEwyBEjTXEy3FLlbxSNZDKwf3xO9EeiRAKVkzcAluKXcPMqMkrDpp1BPxnn7TPE8fvHu4l eJtWE0FI2UehL/YEbD5REmldbzGnWmAWgAUgfm0dSu3fH37RyKRhvYbjCw4HLJaLhP6501 B+Avisf8hlO2cQGDcAA1USTZdkjGliJjHtwHNkdXiWoCX0/+3sglem9KJOr2WDslSbN9tK FADd69bNJL9Ge58wn8YK9p21Qr8sRPA3zrLI0voZ63bZiLmITjqdF/rPEYHE3bFPkk4YcA U+STqLv5Vuph4WhBdJ7c0D7DeChjsFDG4JxSk5BHUfphxkP2ooPN8s+Capuo52aJFBsUBr /9AzQD4/dAS+nQpuVJdzeD33jqdHF7FTwt8MbFWBrf9tBDZ+7C2Z3txGQgXITsdXOYQR5F tDDZXDAR+scpDpAydaRx6wSSQA5ylDLMJU1D19CU77FhzB6ltQKC3iPXm42Oo/ZB8xpyg5 tzWD7w+aiQMXkcrb8rE7Iyob+ouJloH17oI4nGQ2I8l5w+ZBElUiJyxWkYcw X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:31:50 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 03/33] swim: Enable the drive when probing Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" According to the ISM spec, the MOTON bit "causes the Enable 1 and Enable 2 signals to be turned on to the drive." It doesn't actually turn on the motor. When selecting a drive, enable MOTON. Disable it upon eject or release. This fixes detection of the Sony FDHD drive. Reviewed-by: Laurent Vivier Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 4721e073a874..4ddb87977fe1 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -154,8 +154,9 @@ struct iwm { /*------------------------------------------------------------------------= ----*/ =20 enum drive_location { - INTERNAL_DRIVE =3D 0x02, - EXTERNAL_DRIVE =3D 0x04, + NO_DRIVE =3D 0, + INTERNAL_DRIVE =3D BIT(1), + EXTERNAL_DRIVE =3D BIT(2), }; =20 enum media_type { @@ -311,9 +312,15 @@ static inline void swim_drive(struct swim __iomem *bas= e, if (location =3D=3D INTERNAL_DRIVE) { swim_write(base, mode0, EXTERNAL_DRIVE); /* clear drive 1 bit */ swim_write(base, mode1, INTERNAL_DRIVE); /* set drive 0 bit */ + swim_write(base, mode1, MOTON); } else if (location =3D=3D EXTERNAL_DRIVE) { swim_write(base, mode0, INTERNAL_DRIVE); /* clear drive 0 bit */ swim_write(base, mode1, EXTERNAL_DRIVE); /* set drive 1 bit */ + swim_write(base, mode1, MOTON); + } else { + swim_write(base, mode0, INTERNAL_DRIVE); + swim_write(base, mode0, EXTERNAL_DRIVE); + swim_write(base, mode0, MOTON); } } =20 @@ -447,6 +454,7 @@ static int floppy_eject(struct floppy_state *fs) swim_drive(base, fs->location); swim_motor(base, OFF); swim_eject(base); + swim_drive(base, NO_DRIVE); =20 fs->disk_in =3D 0; fs->ejected =3D 1; @@ -652,8 +660,10 @@ static int floppy_open(struct gendisk *disk, blk_mode_= t mode) else if (fs->ref_count > 0) --fs->ref_count; =20 - if (fs->ref_count =3D=3D 0) + if (fs->ref_count =3D=3D 0) { swim_motor(base, OFF); + swim_drive(base, NO_DRIVE); + } return err; } =20 @@ -682,6 +692,7 @@ static void floppy_release(struct gendisk *disk) if (fs->ref_count =3D=3D 0) { swim_drive(base, fs->location); swim_motor(base, OFF); + swim_drive(base, NO_DRIVE); } mutex_unlock(&swim_mutex); } @@ -804,6 +815,7 @@ static int swim_floppy_init(struct swim_priv *swd) if (swim_readbit(base, DRIVE_PRESENT) && !swim_readbit(base, ONEMEG_DRIVE)) swim_add_floppy(swd, EXTERNAL_DRIVE); + swim_drive(base, NO_DRIVE); =20 /* register floppy drives */ =20 --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B386426EB7; Fri, 4 Sep 2026 09:32:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514323; cv=none; b=ekTjwnnGe8s1SLp2o8R0Zr6ke0N238rLouNamuipqLhFkhU2jtQRqZOgnix5wpIX5+HraroVm9p2mJMSagMka6PM9edikdb4eycLryQsKhcgjwSWYLjJkSiAw5XqsqRDHCqRY3BkA0f37dNDSGApS/qrw9PbO6rTEqQJo4p5vDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514323; c=relaxed/simple; bh=6osIxefW9WuJTL+x/nXswa0PPTDUDWFo8rRm7h//FJk=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=cugfiTyKrVdeBZkksbnbm5tHMGyy1deiU4V3JtMiasUyLmkoTrEnR4ccmHZaVbupUcSvO4aORvPxWk7d2g7hnOBEcABcUL08CZqlSOwPEUZSB+8F5Z7IOYZGCBuxXO93qwx922rvl95ONA2TGX4kYoUpsOK8S9/exBMAiSAJ+2g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=F5tyZmQv; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="F5tyZmQv" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id 6FBD014000B7; Fri, 4 Sep 2026 05:32:01 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Fri, 04 Sep 2026 05:32:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514321; x= 1788600721; bh=gDu691Ym/3Wgf1jg+44n93Um7djI9WASUBUmb+nUwCo=; b=F 5tyZmQvernSgBlICdoorrSGFjBendHBlpKOMfMbETiLObACZ/nca9LsujUNhe0Y1 Fyz6QzJyH7EFUulpi0hVWL53Tt7IjodWug7ayFbikd/jiiHt74Npsx5vHYRUY1p6 3iSSxcJnnz5t8EWI0alujWAi7/xMuNagBqUBKdpJUYem+6PQb3x47wEH9hZEuFC1 mONBxfziBpLMRhHShRxj293HfXDcHD5kj3rHWCgx2+oFvhBvD/J/V+rkEro6NZBp A2re9eArggzr0+LPhyq7H7992Lmjv3WKQPu8OA/GdO0MR5zqd1xPm3zZdzErTV5v H7/zRDzaar0rGkz3HltRA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFwU+S4kdAMlQ0v/k0AIIWH8NEZGASJORdIHxKTKTXUZu4/+TuTqA94nuiEUMaRxS Gofh+bL92h8RMpG66xVFwu0W+p9wbh5ZRd08LqtVKnsUP/9Qrp2soVjzNROQy1equ47t7H GqReSb441wEtgq6NIY2eQSaFWVAevL8uK2VrYQsRbjCnFUu9sctSvc8HbwNcOZhBWEvrxc v4dU6ftgbUqTDUj8aqtOMM9o2mrrjTYuxdDT/c0DbswJjHoKR/5ejCxg8Y/5mjJMzYLbmT GHbOCAcx+v5nQg51GRLb73A1+7BY5hn9tVP95J29cL5TZcJG84qND/yu/wkLW77nvFWlU4 yw5nNHdUJw9PFoq3R0XlCxYDTeokboKRRKq2IZTIC1DwsS5pse0c9iPJXqzu6kJU9xupCR eGThEVo9OURlerh/TprEmXWyAOmPwUBszET0DPAGnrAmLjtbim/UnVz1di4MZZ4lHumF1b W77H10Baieug5/VK2zCZM6ICEEXyeVfYyQxpNiYby0cqijK612Mcxip6mkcvwR3zSP4OvO lsWebpEtaOPcDmDZgCX6omrhmAXtq2Jse52rrwv8e+edpfyLI2OC8j7m/Yg16SYI23sCIh 7ntqpWc8uN1d1IkTjzC6bnHzRTGUiWXUqxWigLVYmTCavSeEAYGcybycyuEg X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:31:59 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 04/33] swim: Don't disable drive after every sector Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This fixes multi-sector reads on a Sony drive. The Mitsubishi drive doesn't seem to care either way. Reviewed-by: Laurent Vivier Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 4ddb87977fe1..3f92677ad127 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -473,8 +473,6 @@ static inline int swim_read_sector(struct floppy_state = *fs, short i; =20 swim_track(fs, track); - - swim_write(base, mode1, MOTON); swim_head(base, side); swim_write(base, mode0, side); =20 @@ -490,8 +488,6 @@ static inline int swim_read_sector(struct floppy_state = *fs, } local_irq_restore(flags); =20 - swim_write(base, mode0, MOTON); - if ((header.side !=3D side) || (header.track !=3D track) || (header.sector !=3D sector)) return 0; --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22442443E2E; Fri, 4 Sep 2026 09:32:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514336; cv=none; b=XGYPTb+s5AYtQkRNCvJygLshKUpuUAFlW/6fIkF+V+kUD2qkZ+bRPtLeYfb7POK/M1dkWSt5nO/JKnaRUxd+ACLf7IkPDGrcBMaweo9plXjUWXML+89n86gMmsKIG9sPFKrCIDEnikSDzfuHLYFjHzVotXAyUS8AyBBbQzP4u/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514336; c=relaxed/simple; bh=y2aq5s8D/L5khZxRe/cFjwbxbHS1B0FaloGAs2bTUlw=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=nGoHSPgB04LcEL+vacw/t2h1xUz4g9BRDbJsfbmUmRarR+QTEMWnyYvcw6y0WRqNfA7J81w4TDfh/7VrQYVTEXQeG6UI3VpqfJEIWk4by6rtlj1MMp060IfcYTq2XwR251UFTA0Km0XPalzfOh1pOHY0jAJEDvcJdzKNLk40Tig= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=TlRzhjBU; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="TlRzhjBU" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id EEAD8EC008D; Fri, 4 Sep 2026 05:32:11 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Fri, 04 Sep 2026 05:32:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514331; x= 1788600731; bh=0HLz2220nu44BKt2ov/hAQqSq0Y4djEeSPVWO+Yzb0M=; b=T lRzhjBUMAC1bHpF6dH/sd8jjvIQsd4e33jEjCFggEVzjaLfhnkC7m0IgneV/SzRM RC/ZlID9ijoiWjpmOk9XXXFBZoQe0MOgnKqSSFEEj5SkRaQkRfXuQn5XBA5MDMf+ RF9tuWekQ8t1LEfmWeyXJilMd2kwBKSt5h/Trn2KwOrmJve8LL8qqBSTo99TLWr0 SNjBEJqbpMmCct28JDtQB3wyWmqu/GXcVls1fDN0KGblq0y2KT0yW6+D9Kvfk+25 F963lUZ4baarsvyEQh//9atwA6rR3ARTksTswAwxBRbG3fOyLGvSE+IM3EPiJqb1 ZcqNVyOhWFu530tsdLUvg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFwU+S4kdAMlQ0v/k0AIIWH8NEZGASJORdIHxKTKTXUZu4/+TuTqA94nuiEUMaRxS Gofh+bL92h8RMpG66xVFwu0W+p9wbh5ZRd08LqtVKnsUP/9Qrp2soVjzNROQy1equ47t7H GqReSb441wEtgq6NIY2eQSaFWVAevL8uK2VrYQsRbjCnFUu9sctSvc8HbwNcOZhBWEvrxc v4dU6ftgbUqTDUj8aqtOMM9o2mrrjTYuxdDT/c0DbswJjHoKR/5ejCxg8Y/5mjJMzYLbmT GHbOCAcx+v5nQg51GRLb73A1+7BY5hn9tVP95J29cL5TZcJG84qND/yu/wkLW77nvFWlPz xzjxeqeHHSA0S3wteHlGlMMoWHfHpxu+Hhg/1ZMx56Cel/vnF63CJihimOWQG7EMklLMVy LKmKGb9TdONSTqptOsRCaW8lTFowx+BDlNHgB7qlLu0MetrjCaJcepNNXDJUi55KTUQoQp dEVLCjAH2pyHRiNq5mdtvhJ7AE49SPH7hoR7biGcHVogTXsPNv6lVFHiGIRf0xOwClT8sZ cd2KHV05t5j/gG1NIt9nI3q/oQB3n21pD3TstOimzUWaWxwjnTlRzKWrdwshKgAq81jTHL RpnyrN/Yg8jHQa6XK764YXcoqksPospXPVhmTs06OnlgEVQPwTLn/yrlj41A X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:32:10 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <75714ecc9a12d59511967dc9e24163dc8f3bbdd8.1788513996.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 05/33] swim: Perform ISM/IWM mode switching according to specs Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The SWIM spec says, "MOTOREN must be low to switch modes" and "after switching from ISM to IWM, the very first command must be a clear L7". The ISM spec says, MOTOREN "must not be cleared until after the Action bit is cleared". Perform those operations in the correct sequence. When switching to ISM mode, the Mode register has to be selected with a particular sequence of bit flips. Set q7 low then q6 low then mtrOff. Reviewed-by: Laurent Vivier Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 3f92677ad127..190b2e1b5b0e 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -149,6 +149,7 @@ struct iwm { #define ACTION 0x08 #define WRITE_MODE 0x10 #define HEDSEL 0x20 +#define ISM_SELECT 0x40 #define MOTON 0x80 =20 /*------------------------------------------------------------------------= ----*/ @@ -223,18 +224,21 @@ extern int swim_read_sector_data(struct swim __iomem = *base, static DEFINE_MUTEX(swim_mutex); static inline void set_swim_mode(struct swim __iomem *base, int enable) { - struct iwm __iomem *iwm_base; + struct iwm __iomem *iwm_base =3D (struct iwm __iomem *)base; unsigned long flags; =20 if (!enable) { - swim_write(base, mode0, 0xf8); + swim_write(base, mode0, ACTION); + swim_write(base, mode0, ENBL1 | ENBL2 | MOTON); + swim_write(base, mode0, ISM_SELECT); + iwm_read(iwm_base, q7L); return; } =20 - iwm_base =3D (struct iwm __iomem *)base; local_irq_save(flags); =20 iwm_read(iwm_base, q7L); + iwm_read(iwm_base, q6L); iwm_read(iwm_base, mtrOff); iwm_read(iwm_base, q6H); =20 --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89EFF43F8CD; Fri, 4 Sep 2026 09:32:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514346; cv=none; b=H/S9VQ3XSPHnydlbOccO+m5LrTTyLzXJ6M8UYnFguO8y5MXWTmBewYvt+Dweyny3AaVkKQWuns+0aVo/fLPx3OHw0rNxzk+jQ9ub1R1sqDCvx96rUTd+5V6M64IWiKPgQoRji4G52g0V1rHnNpVq4U54pqcy+SIZ1lsPbNRjds4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514346; c=relaxed/simple; bh=aJKOZOWoXveCddxLIqL10UrkhvVmgi/l2ePVG1uejgU=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=qu+11Bqdpb3+eU2rpj3pArU0Y5zLeed/K64zJaBusx/mjBK19IG3TSw8Nbk2hYISboZt9w4bpEw94a3KjPnhbpY9gKycCZ9hPojtXxNWVBmyFcmqgBNAbe3/0sNgCLl4ivZAvbktP8WrizIy3Ovfm/7sTOudcC1K7gqVUIJejwU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=GZYHYAhH; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="GZYHYAhH" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id EFC6314000B4; Fri, 4 Sep 2026 05:32:21 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Fri, 04 Sep 2026 05:32:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514341; x= 1788600741; bh=xUoVj+IinLNg7uHC8by8czUyQwiMCVAzf8OSJGcKYhg=; b=G ZYHYAhHDC8p4OxMdQ0NKfgwmmO4Kl2XZRcDUg52pDIBey7QJtQy/c/tNtKYCz1C3 WzLEnvlOVX6StRJHrE8IYM8a72Xkomi723UOCwy6qf4KcWeyn/MJuUJWEgTTcXOl N31ed+x6nQ5KrtpWy0ZAV2OpQ9RAYGRUfIc+6n+t6AGgshgadBEmDFWfJOndbA/8 4JnmrTdozmdJskbPtYKI1JX3lqptg+CiYVtKcDkVUL/QZddtNKx5jG0e60V9kCE/ EpxhU2ccb37PeUn+1n7k9t2d9KkGVSpkyk5xMcYY2A0Uh8/Ttf8ABhed7facsUmN rMD8h96kvOi6YJVJioVLw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTF3auZDjEg8eBmaXoTiNUJDm36RpkU4OxNFVDzQbhXoFzPOd3Tywmiq9TcLhKbpyz RtcGsroltMWANqUKCBzA6jAZ/q6gwveBRqnbifBxBFmnUcKWRgTVt+8JgUfvW63RYwPFMX rQCMFgYat6SS5wSRSSuueIm+gtTMdXWEQ9JvjvwnVdqT7PvvrwtNrG6ptAh1E18JsFlUOU FY+OqaHaH+nKcgRcnMziwPz9yDlE96QQVIMo7+0M2GINxA5LefOsEBPICH+QVll4DUoBax jPX+GU5ty42mRSGbQYM10LF3CaX+omFSKyOeAaAbIoNGHhwVd91Wfn6+YFLGNdELAmbsIU A9TP8/dgcF08MrLpN/3dACip6RO+sUxAGYHlyZ2c3nR5yccEz0GuyuYb0+wnPr8B5J9Qmt +Qt8BAgncoIzqGZeMnx1CcwmI+S60/CycgwKJLT3Y38kzF1xWuFJAXYkh19/fv4mmkjPz2 S4rQmv1r0rrzShVHfdQnCCZBiBYmOcs23/cW4H7JmjwAgqeGPC+SKzjtcS4/1bPGJFrqCS YIZb9Dt7sqKRfg84ASPahSem1rrGjlwe3KCL4xdOOzJC9eD0b+t4tBaB2hiXu5CW3Rl3LO Dx+pZs7XRPwi2vyvr0deNFsMXVksw6Xr1vimcbrtnttJM5P+AducejVr1OWw X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:32:20 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 06/33] swim: Configure parameter memory Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The original SWIM chip has a 16 byte memory to store parameters which control read/write timing. The SWIM 2 chip retains the last 4 parameters which control write pre-compensation, but omits the first 12. Hence SWIM 2 can perform reads without any parameter memory setup but SWIM 1 cannot. Configure the SWIM parameter memory with the appropriate values so that SWIM 1 can read too. The parameters used here were observed in SWIM chip memory, using Macsbug, while MacOS was reading from an MFM floppy disk. Reviewed-by: Laurent Vivier Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 190b2e1b5b0e..c2d7ad3f065c 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -796,6 +796,17 @@ static void swim_cleanup_floppy_disk(struct floppy_sta= te *fs) blk_mq_free_tag_set(&fs->tag_set); } =20 +static void swim_set_parameters(struct swim __iomem *base) +{ + unsigned int i; + static const u8 mem[] =3D { 0x18, 0x41, 0x2e, 0x2e, 0x18, 0x18, 0x1b, 0x1= b, + 0x2f, 0x2f, 0x19, 0x19, 0x97, 0x1b, 0x57, 0x3b, }; + + swim_write(base, mode0, 0); /* reset parameter memory index */ + for (i =3D 0; i < 16; ++i) + swim_write(base, parameter, mem[i]); +} + static int swim_floppy_init(struct swim_priv *swd) { struct queue_limits lim =3D { @@ -805,6 +816,8 @@ static int swim_floppy_init(struct swim_priv *swd) int drive; struct swim __iomem *base =3D swd->base; =20 + swim_set_parameters(base); + /* scan floppy drives */ =20 swim_drive(base, INTERNAL_DRIVE); --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46AD543B6C4; Fri, 4 Sep 2026 09:32:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514351; cv=none; b=juWEmjKw3qUiBlairMQUTx0DQqwdAJaVZLaGoQL9fm2BDDW8ZrxVi4qlJ39OPGaXIrQ3QHRjYEsxXViYGgWdxfppf9XFNNUCncXaT3gMwY6sH7jTBCUQNo9DXtBxAFq1xaxd724uz1zjW2hmpvHnfSm+K6ZyQi8WJW/7XFpna50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514351; c=relaxed/simple; bh=TqaVQEtCJF/WR5rdcXCAI6HgPi0OGeO6YWmATyUDaXU=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=JVCYp/iT2eG717b4p6e9hENcZ5o7EcF5HcFFYyAXlB6nuAwWQg7viSWKBGAmdfVWrQ5t46uH/AqgxDvxX9Y3d63xdbcaPJDGayCZbjYA4glCw1f68Nt8KHTg+Gii9ST8fAvFloMi51uWSJvPXSG2TnhpR1/03ABQK1b1MKUwcYo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=FDrQodt4; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="FDrQodt4" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id 7302AEC0015; Fri, 4 Sep 2026 05:32:29 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Fri, 04 Sep 2026 05:32:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514349; x= 1788600749; bh=wcin6JPbkBoF/AQVPzdONl9kW11XqTpdguPq57kuevY=; b=F DrQodt4H3aQvOIBjbvdxrgitRFrGmrhlYXTf/A9aDt8m9TvosvRG7oVSBFbEBulU w8u/Y1k6/H5+XMPFIGBJPJv1iqG9/Fslry27i2ltmlgdH0VdioeDAGqshz6y0VqD FmCSpMyWP+0zoSgvTGxxFi6j+lVl2M698B47UELjqyVcRUUF71or+X4DKInVUvbu s/DA2kU+uQ87Uc119zlDmYH4N12GokT3e9igd5HCyZn7EbzFabpgqk3iI0xWIyDT 9K9biYLvODFplnbzx5fOK7Ng9rWHvV8ZBASW+HoV+u8I43KkgGbUatmOqCp5AjXt 1v80AYL5CBTpD6+Qm4rCw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFZ/TtYWX7QRSPqbWdhFvGKPdYLqSrS0kW5tw/ccCSeQwGXLU8z8+n4MTGG5Fz3xO fBhPKm+HgWFmiq+gJDvSVIfRvZvgV672b0RABACnDdhJF/iW3opz+U3/SP3bVUvVx8Q287 Ap1gWmRx+bP8FRnMF0HKeE0yfsMRD8AYBXtaUsZs5aI7BW+fV7e9Q0YJu0hP5K8l60oxGK XrcuXNo1hSmleRjGCb9wMFpOFKoRGwYOR+2UyWTZOvcSmWg9D5Za0czKtKfTDaJ7RbQZgm lIJH+OOpA0D60VJW1h483ZeutJ4e8G1K0sL6VJD12jwsAudayvIunnWKGaY8cBa7nccFlF 3vWb+n1kTewjAuLKbTmHoam2Grwkcj7+e6PXX3ACssWgh4LDa9ziRz6myZFfJYipTBK3zP 5lDzKAEyusid/TjN1ddEQ+7OeHIkzWz9T9PyKOyaBwNUYPfIFzkuZzFbiNT08Y68WAu1dj sjcbB0XSCt+lpStP5uUmswPEqENWG85Zh3yY4pjM4hqmhteSAi0diNbFj0ggoLFmwxKobM uvXS0b3hqbr/+lKs85B5gkyHthTxXfQNv+yhJES2Fkw8vkKWZuHRuIMU0QYymcIeTaXdRS 5qz/C0Zmw/P5V0WvM8gpFYucgC7R2/OX4WOU4Xay44qoyemESweZJ2cr0QAw X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:32:27 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 07/33] swim: Refactor SWIM setup Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The write to the setup register is really chip initialization, so do it in swim_floppy_init() rather than floppy_open(). Drop the udelay(), which was apparently copied and pasted from swim3.c where it presumably relates to interrupts, of which this chip has none. (See also mkLinux SWIM 3 driver.) Cc: Joshua Thompson Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index c2d7ad3f065c..b8384525fc9a 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -628,8 +628,7 @@ static int floppy_open(struct gendisk *disk, blk_mode_t= mode) fs->ref_count =3D -1; else fs->ref_count++; - swim_write(base, setup, S_IBM_DRIVE | S_FCLK_DIV2); - udelay(10); + swim_drive(base, fs->location); swim_motor(base, ON); swim_action(base, SETMFM); @@ -816,6 +815,8 @@ static int swim_floppy_init(struct swim_priv *swd) int drive; struct swim __iomem *base =3D swd->base; =20 + swim_write(base, setup, S_IBM_DRIVE | S_FCLK_DIV2); + swim_set_parameters(base); =20 /* scan floppy drives */ --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B569D37A829; Fri, 4 Sep 2026 09:32:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514361; cv=none; b=lTJRveynXJAuxo7dvoQ06m3oEL7fOvsclcZIDZ2ZujgoXq+NQpoQ4CxcONkFPM0JbRRHzz+vA05EBf8UwHhKLbT/ODEoTqhuHD6yAnRhidowzkWUfBQaZ07Va37byIDdBSv9cMpHU/szcT4COxBVdwRw0nkQQ/1V3pZyF6GKZfY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514361; c=relaxed/simple; bh=gjAFfbgXquirRMg/FEuOcy8jtQ7XXsL92yMGScg18ao=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=b8CnToHZr7jxnXuGUKEbTA5g8XQzno8r2LM1ci85dJvDZz9/o9Tt5DU7a5LnvMKXDIaYr7X6WuYogXxHS49pBq5V1h/SkbEEOBG6Ez3KwVSBRd9L1sqy0Es778aHJpHcPUk5LVvsXDnaKiiMkbPxWEO0Qc9VU5jevWUCpTHnAS8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=QB9rHKxA; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="QB9rHKxA" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id B219414000BA; Fri, 4 Sep 2026 05:32:38 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Fri, 04 Sep 2026 05:32:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514358; x= 1788600758; bh=vI95rHJq6hFCrnTGLxzjtCgat4bxYxSiGX3ThWsps3A=; b=Q B9rHKxAIzsbv6yqqno5N7T7tCPkoeRgwS5xQRQY0rZwAJMjiphEKDpPTjCRdWxF0 Fr40LaSkqsqfc8qNVpK0oWv/YOxgGY7dG8nheZsHT7DCxK/wwATcIom9MlP6pKE2 Yp0fDPBPh6N8dSdbdWtPATLxPT80ODZNPRnPvVkcQH/tbjZE8JWUukXZI+IyAqPZ hGavK+/e+HXZwmN+2s9nQVb2ALPRGepJGfjjXdJVFZvTXY1ZVx8TqhzGxGKyU3HJ b4k5ptaAMShsEK4Q4JwcLYRxfW0UjycUuKy8JCN/VUvhm5rWcjDywKl5PpUZtDyK Hp7VaexsjEZ2aoAnyxZyQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFwU+S4kdAMlQ0v/k0AIIWH8NEZGASJORdIHxKTKTXUZu4/+TuTqA94nuiEUMaRxS Gofh+bL92h8RMpG66xVFwu0W+p9wbh5ZRd08LqtVKnsUP/9Qrp2soVjzNROQy1equ47t7H GqReSb441wEtgq6NIY2eQSaFWVAevL8uK2VrYQsRbjCnFUu9sctSvc8HbwNcOZhBWEvrxc v4dU6ftgbUqTDUj8aqtOMM9o2mrrjTYuxdDT/c0DbswJjHoKR/5ejCxg8Y/5mjJMzYLbmT GHbOCAcx+v5nQg51GRLb73A1+7BY5hn9tVP95J29cL5TZcJG84qND/yu/wkLW77nvFWlFc Zq9Y320IajawGuEAzRcsWsgD2Bh1Q81t7Oe8GZfmWdoQgYxhsImRYXDYF9RRMCoSq2jqXc XWiDqEwCczHxRZgEsWSkOIqVye6m8YeucUzr/uI9ni4CYb0wjk9BKVntSx5f8mGTDBi9aV RBRlAgbq3e41FJC0pgXbmYbQK1AG7E6mgOpjapQp3dkwiw9TrdiDma2iV0JcF053BVjmrA SqIdEsjA+fp7+UZyBwPgAJJpyq0TbcD5quyZRhqV979m4DL6CtrWd67Rnzn+s6UFUytO1K 4ZvHpb0gQVACWlLtJbTXoJYhtYMZCvnN29xNea7il/UGjRUMn7pYQg/1n1/A X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:32:36 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <483efa2f8ac6beb2a2d4fa2d8b431cb1a8b560c7.1788513997.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 08/33] swim: Enable clock divider only where appropriate Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some models have a 16 MHz FCLK oscillator and others 32 MHz. Put this information into the swim device platform_data so that the driver can correctly enable the clock divider. When this is enabled incorrectly, nothing can be read and failures from the Error Correction Machine are flagged in the error register. Cc: Joshua Thompson Acked-by: Geert Uytterhoeven Reviewed-by: Laurent Vivier Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson --- Changed since v2: - Code motion was split off into a separate patch. - Use 'bool fast_fclk' instead of 'unsigned int data'. --- arch/m68k/mac/config.c | 31 ++++++++++++++++++++++++++++++- drivers/block/swim.c | 9 ++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c index c0033f885ed4..b745cf20a71f 100644 --- a/arch/m68k/mac/config.c +++ b/arch/m68k/mac/config.c @@ -984,8 +984,37 @@ static int __init mac_platform_init(void) .start =3D swim_base, .end =3D swim_base + 0x1FFF, }; + bool fast_fclk =3D false; + + /* Models in this list are supposed to run FCLK at 32 MHz */ + switch (macintosh_config->ident) { + case MAC_MODEL_CCL: + case MAC_MODEL_CCLII: + case MAC_MODEL_LCIII: + case MAC_MODEL_Q605: + case MAC_MODEL_Q605_ACC: + case MAC_MODEL_Q610: + case MAC_MODEL_Q630: + case MAC_MODEL_Q650: + case MAC_MODEL_Q800: + case MAC_MODEL_P460: + case MAC_MODEL_P475: + case MAC_MODEL_P475F: + case MAC_MODEL_P520: + case MAC_MODEL_P550: + case MAC_MODEL_P575: + case MAC_MODEL_P588: + case MAC_MODEL_TV: + case MAC_MODEL_C610: + case MAC_MODEL_C650: + case MAC_MODEL_PB190: + case MAC_MODEL_PB520: + fast_fclk =3D true; + break; + } =20 - platform_device_register_simple("swim", -1, &swim_rsrc, 1); + platform_device_register_resndata(NULL, "swim", -1, &swim_rsrc, 1, + &fast_fclk, sizeof(fast_fclk)); } =20 /* diff --git a/drivers/block/swim.c b/drivers/block/swim.c index b8384525fc9a..1ade5c497e10 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -806,8 +806,11 @@ static void swim_set_parameters(struct swim __iomem *b= ase) swim_write(base, parameter, mem[i]); } =20 -static int swim_floppy_init(struct swim_priv *swd) +static int swim_floppy_init(struct platform_device *pdev) { + struct swim_priv *swd =3D platform_get_drvdata(pdev); + bool *data =3D pdev->dev.platform_data; + bool fast_fclk =3D data && *data; struct queue_limits lim =3D { .features =3D BLK_FEAT_ROTATIONAL, }; @@ -815,7 +818,7 @@ static int swim_floppy_init(struct swim_priv *swd) int drive; struct swim __iomem *base =3D swd->base; =20 - swim_write(base, setup, S_IBM_DRIVE | S_FCLK_DIV2); + swim_write(base, setup, S_IBM_DRIVE | (fast_fclk ? S_FCLK_DIV2 : 0)); =20 swim_set_parameters(base); =20 @@ -931,7 +934,7 @@ static int swim_probe(struct platform_device *dev) =20 swd->base =3D swim_base; =20 - ret =3D swim_floppy_init(swd); + ret =3D swim_floppy_init(dev); if (ret) goto out_kfree; =20 --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B0AD36655D; Fri, 4 Sep 2026 09:32:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514369; cv=none; b=KFx79YdG03CsyKm3KwVWUTi12R0helprm+uwpUNUJQ0PR7GNyhnp/WG4NgbSFRA1dP29R4wsL2wt/vR0qGCLKP/SF2lfnW1nTeYwo5k3gV5jLQllhKps6tTOsdZg0K2WuHzqf2KhXrtCUAbY0dJI7J5xYEpm/2YAWxcnyrYlpX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514369; c=relaxed/simple; bh=dRxuwALk9YTnOMKnzKeofGyeSaQ0m7a8H+eg7bi7LxY=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=FHYBBe1r23bioCPLgQx6/xNJUCx7kfisIRl1asuzfTqJ7ekYC8G9EbMIyI42ZFdllxUWOX54jRuUAikjXTtbCLb1G01/WP5imsC/meMb6zCjjwWUCYsi2DIcGXKMLSVj9fRp/Pjp9w9qKK1uXjqLJtp3vmoZtT3A0e0CiIOFKfg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=GbWKv6nQ; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="GbWKv6nQ" Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfout.phl.internal (Postfix) with ESMTP id D7394EC0077; Fri, 4 Sep 2026 05:32:47 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Fri, 04 Sep 2026 05:32:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514367; x= 1788600767; bh=bFm/w+S7jL9RAO8mk/A15H+X8AjGs3DD7Z/cWbm6Tao=; b=G bWKv6nQL7sbe6+0eRgTKF1oBRhW5UwRe7qe2guazWoX8jcoAul6Ax2is8D2HxSOB I3DE5424H5/QPWO+SUfavPRSwQr2vnDkr8GfJ7KJ1hiXZ9ZjU8/i9toAYG/tre1u eGRxqhZJT8g1c730o+QtjtcRS++jxMuWVEtK5RORZpTuJ3GnqZ6Q6JWv2O041l3t DuI2rh6oeW7UxbylturuCaTgWpDFpQ+ixDr4avdwtxnE2ecv2cItUG2clG2r/VAQ FtlW4Q4TZzco48a7+1HlGqDNnR2NPVAc4bAndCHCIzpHUZjCHzC2DDGuRk1bzV0l g+jiD7HoPViJdOsJnuBiw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEAKPWJVEMqJ16jAjOL9FB/rBffUzJbSVLQHlq9+RC52fsBvb13o/7yjvGYTuY3IH ZNCMm3A3s3Wzl4RLMlWp0jCSYNVS7BZQKRPO2yqi1PfebCSoLOeHqK6FATWT8bd3IKpoKZ CEwyBEjTXEy3FLlbxSNZDKwf3xO9EeiRAKVkzcAluKXcPMqMkrDpp1BPxnn7TPE8fvHu4l eJtWE0FI2UehL/YEbD5REmldbzGnWmAWgAUgfm0dSu3fH37RyKRhvYbjCw4HLJaLhP6501 B+Avisf8hlO2cQGDcAA1USTZdkjGliJjHtwHNkdXiWoCX0/+3sglem9KJOr2WDslSbN9AZ 9w7O41MwDchT6dcIB/ylTa1ARjQAipj4a5vGdq+12spXTRve241PxWv/ILCej2HM63ehSO 7ef9VoyTqpIRf5MlmqdqNx/esu3RkKqVsQm7RyAtTjMkHdUcY/MqI1qesKyQYIGxkAT0Vt zoyCGtnBDTudJXOF7y/xqtrR6Cz+Q2PMfWNDs7ABqx9+x4PlKCnTPRVnOzsZaFqLDy/RSW vEbfnZZjZlsnGvfJBbmDO6lPvj1nbCadNg2T7hI14SEXdKbTvsCXQgxWUn/6olcarAwouN 8lHPpgUDzNy9ZU5EkG6jyhuGZdb7OCXOhb7JQtNhIsoTFmsaP8Qp4ltzTb1w X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:32:46 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <7ea60e0bf6135b9bcd4be0991a257d4c5de22bb3.1788513997.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 09/33] swim: Don't start motor until medium is present Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The spindle motor should not be running when a disk is to be inserted. Don't start the motor while the drive is empty. Reviewed-by: Laurent Vivier Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 1ade5c497e10..64073e8f6c36 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -630,8 +630,7 @@ static int floppy_open(struct gendisk *disk, blk_mode_t= mode) fs->ref_count++; =20 swim_drive(base, fs->location); - swim_motor(base, ON); - swim_action(base, SETMFM); + if (fs->ejected) setup_medium(fs); if (!fs->disk_in) { @@ -639,6 +638,9 @@ static int floppy_open(struct gendisk *disk, blk_mode_t= mode) goto out; } =20 + swim_motor(base, ON); + swim_action(base, SETMFM); + set_capacity(fs->disk, fs->total_secs); =20 if (mode & BLK_OPEN_NDELAY) --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28A25382299; Fri, 4 Sep 2026 09:32:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514379; cv=none; b=f01p1LLMoIbhtWLQVPeOeP66gQGwcfqSTpoiuSJmrFOqeP3Ma8hqJcWxS3O3uT9J2pH467nXFSKJWWLCIZzgADLP+Wm4X+UgasotHDZ9JUaroavJIcMGlbsCwl09FLdPRqq07pE9HcL5C8pQpR1R4yf8qpZqCwEZAXlNVzv6mEU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514379; c=relaxed/simple; bh=2pyPVKp38UMdwJMmglsearybtZGlT08TQCtnZBASEPc=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=kCxbF0Mtmg8h1i1ByxZfIWPOvP2InuNczPshjehgJVNB3DaAOYOz4s1pjPOhkPU/nxhHqcFWJvYd1DPkxeS29Xvam99vt4JgIprAhWmRrsoxAwCOsIKX2BR43CYjE2FacjGfjCB/wB916TrbJ0u/3m6dEHw42mZe6oEYeF9kROs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=O9xwlKPh; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="O9xwlKPh" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 46334EC008F; Fri, 4 Sep 2026 05:32:57 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Fri, 04 Sep 2026 05:32:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514377; x= 1788600777; bh=5vdrbn+T43CZpZXYEaWsMOzKdGDNT+c/uB7d2c8BDu4=; b=O 9xwlKPhda2y9ql+m395qSIakgBLkyLnv+l459r1PRyAhgbao4bvFzQJQu4C2kwW8 b113CDBLseg/bWlaKiG/qSsSS+yJTVwB66hpNiQcvM23Ky8/ZnXfPHixAZk49uo/ 1OKCkkVUYaIzFrHgZGzH44b+Eok6k+vHqbEZeqD8Msr7aFMjLqaTCXf2zdya259z 2yvR97IvWwuN9dsniwEwPKc3NJPf+koh30T22vXZkuKCxKrZ283IhL/ineFxBmj5 BKlXXJEfGxBkzf8A8URmpiloNNVYolyTPUTYLmPNu+BoPy9/Wi4cUsQSLZ1QRjFF B4NqxmUuFtuPRFS4FfGaA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTF3auZDjEg8eBmaXoTiNUJDm36RpkU4OxNFVDzQbhXoFzPOd3Tywmiq9TcLhKbpyz RtcGsroltMWANqUKCBzA6jAZ/q6gwveBRqnbifBxBFmnUcKWRgTVt+8JgUfvW63RYwPFMX rQCMFgYat6SS5wSRSSuueIm+gtTMdXWEQ9JvjvwnVdqT7PvvrwtNrG6ptAh1E18JsFlUOU FY+OqaHaH+nKcgRcnMziwPz9yDlE96QQVIMo7+0M2GINxA5LefOsEBPICH+QVll4DUoBax jPX+GU5ty42mRSGbQYM10LF3CaX+omFSKyOeAaAbIoNGHhwVd91Wfn6+YFLGNdELAmbsZU FpNB2ppgyUFZD92QKOymv6jrHe9BBMzUzrzTpn473sL+yhlxNHHlWfLREpq8Np41dGqMRS 4JCE6HR+GY/j0946JTWanXu0+5C0/nGjuTIdCqG5Tr5eGxdKTJtK+PEPLzYatCstNHpxqJ e1NnUK+wIVm2++mi8cmfqvCQdrdklu203/hoIVQORYfyBM8OwleIiC4zPTEISZJNnnB2sk dwrXUlJu2tt2ChBgkqfIMBpzL/xV4BJ7eNP/wY6vVqWwAij5fpnNm/1BC60WTEUbABq3A5 cC8KrmMEKXXGd7Umj7KxUH8zX+ZZtsenHtMgVIAkIeAPitW4H6N0Cs2T3aCw X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:32:55 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <119e799afcc00d6bd4a479c31e0c960cb1a1d71b.1788513997.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 10/33] swim: Recalibrate when drive is probed Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- Changed since v1: - Refactor swim_add_floppy() slightly. Start spindle motor before recalibration if a disk is loaded. - Change return type of swim_add_floppy() to void. - Park heads at track 40 because that's what MacOS does. Changed since v2: - Dropped reviewed-by tag due to unreviewed changes made since v1. --- 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 64073e8f6c36..5daa60938505 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -412,6 +412,7 @@ static inline int swim_track00(struct swim __iomem *bas= e) if (swim_readbit(base, TRACK_ZERO)) return 0; =20 + pr_err("swim: track zero recalibration failed\n"); return -1; } =20 @@ -456,6 +457,7 @@ static int floppy_eject(struct floppy_state *fs) struct swim __iomem *base =3D fs->swd->base; =20 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 =3D 1; fs->write_protected =3D 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 =3D swim_readbit(base, TWOMEG_MEDIA) ? HD_MEDIA : DD_MEDIA; fs->head_number =3D swim_readbit(base, SINGLE_SIDED) ? 1 : 2; @@ -610,7 +605,6 @@ static void setup_medium(struct floppy_state *fs) fs->total_secs =3D g->size; fs->secpercyl =3D g->head * g->sect; fs->secpertrack =3D g->sect; - fs->track =3D 0; } else { fs->disk_in =3D 0; } @@ -759,24 +753,33 @@ static const struct block_device_operations floppy_fo= ps =3D { .check_events =3D floppy_check_events, }; =20 -static int swim_add_floppy(struct swim_priv *swd, enum drive_location loca= tion) +static void swim_add_floppy(struct swim_priv *swd, enum drive_location loc= ation) { struct floppy_state *fs =3D &swd->unit[swd->floppy_count]; struct swim __iomem *base =3D swd->base; =20 - fs->location =3D 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; =20 - swim_motor(base, OFF); + fs->location =3D location; =20 fs->type =3D HD_MEDIA; fs->head_number =3D 2; =20 fs->ref_count =3D 0; fs->ejected =3D 1; + fs->track =3D 0; =20 swd->floppy_count++; =20 - return 0; +out: + swim_motor(base, OFF); } =20 static const struct blk_mq_ops swim_mq_ops =3D { @@ -826,14 +829,8 @@ static int swim_floppy_init(struct platform_device *pd= ev) =20 /* scan floppy drives */ =20 - 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); =20 /* register floppy drives */ --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00BF144238C; Fri, 4 Sep 2026 09:33:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514389; cv=none; b=mMnWrsaXg/hzKU0glRruEsNInVxmtC2ibYvkriL5Ba2kF6YfXOjg8uJZRz9NJY+MmMcq5AFKvbGyJzplYiXZJ10nQajfXSPFVNFBi5/t2Slr6Uhg+byuogdc0/aq/FkDBiI3+r1uTdIhomZvfoDO2ljb9J19ZfF1gz2QT8wxLe4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514389; c=relaxed/simple; bh=2Uzu//XUNnh+b9k8CRpdbpw9MLPBTH5AazZ9f6Wg14w=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=JWw5jYhRLSip+7U3OVS01I24FQLYQXYQyA4zXAFkZzW1/A5olLGX3zVR8oRYfU/Yoqj1mtfJPDMq+u8TGFb0I9hTAKpL+6646ikLwFIVVUXUihKnzV2q8JYcAOGGBucKQqsVT9i1A0uFZLOHWEHqy+E7a/zo2uXHnggC/7eFpGs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=n59QkZtZ; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="n59QkZtZ" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 1F14BEC009D; Fri, 4 Sep 2026 05:33:07 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Fri, 04 Sep 2026 05:33:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514387; x= 1788600787; bh=eYtGit5qYI8E6j+PcO1ZDRQ+9PgxfxVmav+LBUHcTGw=; b=n 59QkZtZ4sLBlcmO4dpgbsSYZre/UNh9rBo7eEfOYiQZJKXkiSxamQZzJHCpM0Qpy L6oo+0wCy9U0cNdFZyYIcIJmOO8KGPgK/MXRFk5w6tcxth0ozabYlZrrGxhGO5fG fxWdblQ2BK04Acf9/t6rcQpwOIZfl2Lq55q7naB+ltwd5FBROzy5FcBifkgSe3eP 4fCE/dCuo/fCL/LXjoFsoRW4l+sqzxg9S27OSsZHGVs03oPgtoLfkr96C0CGt0fo SCycWixe1AA7SAoFoeKYKzxHrNem5ZCAvHzXF6aZ+k1Em8i6FKh4APz++gKBl8Bc 0pa3ZlozfE3UZR+7A7Uvw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFwU+S4kdAMlQ0v/k0AIIWH8NEZGASJORdIHxKTKTXUZu4/+TuTqA94nuiEUMaRxS Gofh+bL92h8RMpG66xVFwu0W+p9wbh5ZRd08LqtVKnsUP/9Qrp2soVjzNROQy1equ47t7H GqReSb441wEtgq6NIY2eQSaFWVAevL8uK2VrYQsRbjCnFUu9sctSvc8HbwNcOZhBWEvrxc v4dU6ftgbUqTDUj8aqtOMM9o2mrrjTYuxdDT/c0DbswJjHoKR/5ejCxg8Y/5mjJMzYLbmT GHbOCAcx+v5nQg51GRLb73A1+7BY5hn9tVP95J29cL5TZcJG84qND/yu/wkLW77nvFWlq8 qJxKAmG8i1t8IBzPGAvhuSi9XzJ/z92etVKa0+MLuNwvj0BPT3esku4h/1lghd1stAJsx3 oeO3m6ZROqowDl3uYXY/PDPil6u8mkPPDt0S+ylJK1hzDexZ389juuCze11Ujm2T0brsl4 EFhjpp18+o0WwAJaHYSyZ3h7kiwEti+nzXeMrs/oNidCkeKGHkOLpUKu9giQhJw9SdXuW6 +dgw6WakK2rn42eoLzbMhKrR810jNFycA2wIl2HrCp9SV934NBHmPZHFB2i8dmpa6tfOze DHqFrd628L3ni+wR0jzWOqv+HTNx8m1HfoQ8/6pxwlPtPT8hxhewsF+jS4ew X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:33:05 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <6d17ca20a7286c1d74833b29510c506a66d96e6f.1788513997.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 11/33] swim: Add track zero recalibration delay Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The UPD72070 spec indicates that the track zero sensor can take 3 ms to stabilize following a STEP command so add a call to msleep(). Remove the duplicate swim_readbit() call as there's no need for that once the sensor signal has stabilized. Reviewed-by: Laurent Vivier Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 5daa60938505..cf5470cfd775 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -402,16 +402,15 @@ static inline int swim_track00(struct swim __iomem *b= ase) for (try =3D 0; try < 100; try++) { =20 swim_select(base, RELAX); + msleep(3); + if (swim_readbit(base, TRACK_ZERO)) - break; + return 0; =20 if (swim_step(base)) - return -1; + break; } =20 - if (swim_readbit(base, TRACK_ZERO)) - return 0; - pr_err("swim: track zero recalibration failed\n"); return -1; } --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96809442FCE; Fri, 4 Sep 2026 09:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514397; cv=none; b=S9HpD9ijtm+Uc5QCjWost2DlQisV7sz23RM3LzSP07YUYcD52biDYjD/0IQ+3pAZN6Hi0FzZ+mC/AZpFEtWLR4Wht47Wmo3OnwnADwQKlxYLSRZG9/lvb0a6mON83ZNSIAXjG5aWsooBWs7RkHmHx/Zftq9OKHtCbO87ZiYDFV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514397; c=relaxed/simple; bh=nJY7w7cEh+7c64BYyL0LKpy2zDQj/yRgCMwLxC8ocPY=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=SXYcOgFW5QMMhgHXu+eYBHHbyZUevB0eGzdH1pntdWBptnzV1q3YdkYUEt6jEi5JDDhcFC1ygcup2IqBv1cX/Zgga5ADA9dveMmTOLI0qV5fm8H50T+2a8ETnURrW7Ba2CYp5p0AuYCAiDAkTj7qWWBk3KM3/Ezp8kx54mDOOnA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=B0cusFMH; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="B0cusFMH" Received: from phl-compute-08.internal (phl-compute-08.internal [10.202.2.48]) by mailfhigh.phl.internal (Postfix) with ESMTP id CC3C41400060; Fri, 4 Sep 2026 05:33:15 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Fri, 04 Sep 2026 05:33:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514395; x= 1788600795; bh=C0D7P8G6hTvt2FE5SH/vyr6jLBpriqH6H04iEj3x/3Y=; b=B 0cusFMH0dJT9CkrhKlow2Hqh3tHMmJlpekBnZT7dyHK4Df/KM6f78G45G7Pt+qgS 7sOqa2Hxgclok8gHWsfb6FVkRn7357bVJU45SORd7rb3DDVFrHmECeyoEycbBn2h BiPXYmT2O9OYghHBd9J4O8FcoUFpXq1BNpSFKhj14YX7Ggxz1/0+wRurI2MObUIy vvtN3WTP+RrQViRSFSYMumFVjeyg0o2RHm1Jro2/P9C0MsSFPb6rfztQNjp0F0F8 Ym7mi0PsNT9HH9vHFDT0fAyJHzp79Burux62DLMSHjk/EXIj9i7PDpGRmkLcSaJ4 jxtXUtBxw2DTWNWTgD8Nw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEShLUtpn7KHoPqlWeaFg8DtB+/+ziGqKciJgq9h8mxt10y+H//Vk+lTV5bBElgOf OJVHuQ7kWguYfALzjze3yj08Q93Gx0vQ2Rc6DheMROSt10Fhzuw7qa6lOvsUomUINlECu7 1gSGg3jE7tjuf54GQHw7Neo/DLHqg64dG+TJH3CTLFsovI7YuE6OvacA1XKtUXfCp5h+SI zMofHNYFCT0F3CzxXunyfBvVYDqHfQ37QvBka1g1fsKMciRCDxbiA2txribhyQoWCGZ98D NlAPrXmT5j9Wry+yrW1taOjx5QR3+y7SnDI1+hMrCGWBDRvDKvW4Xpge97CgPIwi5yzGWW leuE7IxeDEIr/b6eITb8Aj2OX1HXWvEQCgDNju5ZAKbcREX/c0Ue7Od2tCVNLsexU/IWT7 h47XjqZHsXYEm+pV2gC/wRTfO/OAJdczBW+xZd+Ud2Elb0j3Vl8nkNOEtXWKZEvABhi5BC weqs5EdEGmFB5ZSRfGV6slv5AjVQENR8Wj/UDG2xLHTM2C0Kgp3ATnSxa0dcuOZ1OZDy7y QHc07lz0G08IRzlUDhpBezB+0zgZvA5dIpkXboZuvUNB5Dk1aBwIQ48waN31ylvBlSQ5M2 4vNKvft71TuPYFxEKXZ82rG+tQzhEjypdzYmlukdV2XzldF1FPrf4YhwzVJw X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:33:13 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 12/33] swim: Handle FIFO timeout error Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When polling the FIFO for a mark byte in the sector header, don't return zero if the timeout counter has expired, return an error code. Reviewed-by: Laurent Vivier Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim_asm.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/swim_asm.S b/drivers/block/swim_asm.S index 3d7a2d87595a..208622ac4aeb 100644 --- a/drivers/block/swim_asm.S +++ b/drivers/block/swim_asm.S @@ -79,7 +79,7 @@ wait_addr_mark_byte: =20 tstb %a2@ dbmi %d2, wait_addr_mark_byte - bpl header_exit + bpl signal_nonyb =20 moveb %a3@, %d3 cmpb %a0@+, %d3 @@ -136,7 +136,6 @@ crc1: tstb %a2@ =20 tstb %a3@(read_error - read_mark) =20 -header_exit: moveq #0, %d0 moveb #0x18, %a3@(write_mode0 - read_mark) rts --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE2AA442397; Fri, 4 Sep 2026 09:33:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514406; cv=none; b=rGneH+VFB5vfOPQh8zu0xkBlorUrGxvLnTfQ5r9i5QoA/Zw42w3MCHAG2uF+qmJSLkYV9MfmtFo+iCLqdWntvAlGKcSYrg4qbgXnQa6wvZPyB1zglgT+O0InViIWTp5yVve0Drdh9+ObEnIRiD45gMHGBE7mRysEcyzYeADVm0I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514406; c=relaxed/simple; bh=nOG4yfH5/Texvi3H9mlwkPnUvUaWqgsIEIoJ0CLpKC8=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=W+BiNbqfAHiA0p7+huCeYLkrPvIHxDjwh7gNBbu+eApiUl0FQ1T2rBWfgVQg+5hWghtUB5WeaqpwF2eyJKzLP2hUq6SpMVTc1egTaORLMXsbW+k36UJ1cuWW6lqc0XqNsAVSxfa5mG9H3vY+WY/8EnZddioof0d6Y+NzhsR/QNE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=IWTX2SOI; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="IWTX2SOI" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 141A7EC00AD; Fri, 4 Sep 2026 05:33:24 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Fri, 04 Sep 2026 05:33:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514404; x= 1788600804; bh=dapjyK1m12iSEcR0ao3su9fLZHUPrMz/Un6E1mAq3DA=; b=I WTX2SOIMekA67bKLIrV5wo19wsdRtlz+cU/MQr6QNpwSiMAq0U2dviw/aQfsQaW6 //dURvX8jfBf4bRTmnM6qeMECslkt9Z9dHa72x/ed8UkiAkEznVom+Ftp7t+xt8V qa+/oIwf9bGp2dV7r3a7Ns3zBq8lJi0bC3RxZTGYR6BXK4IlpEqZdHYIoHp+FxqA Vw0FX/tA4F6Tb5fLl1+EYcH9ZWGK4pm1fHNJiK0xgO3Os0VAN/4PdqIgQ0TxVAYf 40djs+ejZu6SZOdb6CESWd9y7G2SbSFyEebAdI3ALGcuhPr2/4a2vIUf1y9yb6pA HHuKJysLvpfkUDN969a5Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEe+0K1AexRW5VKg6Igspc49h8df5hxyd+FQ2UxEzuyTDi2ZhdiSThGiBIwkdDgU9 3rC08hmhwBNxNoNuM+ycNNv31fkYVLn6pBr27tqKRLQMq1NV3DFc39Iqyivnkegn2UfxIv roQdqcH3VVXGJWlrRZqsrGKoS9rmBFYj7GFxW36+XXMnxcw5HiNtvMvRco3OYXN6UY/K0t SqGzE69/GT65xt5VU7CUtrbe1RJV9Of5WXGGzQneXN7Ylc6viWLtf2PMOfqRj9Ut2W6+Hz DfFSoa/BAnz3IHwFnQcu4acvCfz7MIdPrcCNMUsADy4T129cFo7Yojs7dtan6e38DtGhl4 tO5xlyppLlfD9dmZilBK/d51Px4d+XSzzVk9UJkUgSInlObRclmSiE9V/s82/DGbmeH99M SpMVh1ZiILJwtCeKs7dwVQ1PqSxUu4vB8CfqvaEb7rbUU90rxYcL6Ax3dkMMRwtLusKGcr Z8v6ttFyqvbhLbAWf/lH+bnfT6j5vdb43O2azrCCa/Q9Mpz+baHmQr9bIze/fN84I9IEeG 98+ahh/2/rg7JgiAmqnOUi/MQYmSyaXMfUs1savUzjcRc+Wmp5iQWHAixqSLCdN5HhyOz4 c7BG0gZmQ12jSrvGjdep1ClQ8bD+Sw1z9sEJAaN7NkXmlVBn7bFi+45hKHcQ X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:33:22 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <28322f0cbefd865bdfb679bab4352c111996795b.1788513997.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 13/33] swim: Simplify return value initialization Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Initialize the error result once only. Update the result only after a successful read. Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim_asm.S | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/block/swim_asm.S b/drivers/block/swim_asm.S index 208622ac4aeb..31fc63b074dc 100644 --- a/drivers/block/swim_asm.S +++ b/drivers/block/swim_asm.S @@ -47,6 +47,7 @@ swim_read_sector_header: link %a6, #0 moveml %d1-%d5/%a0-%a4,%sp@- movel %a6@(0x0c), %a4 + moveq #-1, %d0 bsr mfm_read_addrmark moveml %sp@+, %d1-%d5/%a0-%a4 unlk %a6 @@ -61,7 +62,6 @@ mfm_read_addrmark: movel %a6@(0x08), %a3 lea %a3@(read_handshake), %a2 lea %a3@(read_mark), %a3 - moveq #-1, %d0 movew #seek_time, %d2 =20 wait_header_init: @@ -137,10 +137,7 @@ crc1: tstb %a2@ tstb %a3@(read_error - read_mark) =20 moveq #0, %d0 - moveb #0x18, %a3@(write_mode0 - read_mark) - rts signal_nonyb: - moveq #-1, %d0 moveb #0x18, %a3@(write_mode0 - read_mark) rts =20 @@ -149,6 +146,7 @@ swim_read_sector_data: link %a6, #0 moveml %d1-%d5/%a0-%a5,%sp@- movel %a6@(0x0c), %a4 + moveq #-1, %d0 bsr mfm_read_data moveml %sp@+, %d1-%d5/%a0-%a5 unlk %a6 @@ -228,15 +226,12 @@ data_crc1: =20 tstb %a3@(read_error - read_mark) =20 - moveb #0x18, %a3@(write_mode0 - read_mark) - /* return number of bytes read */ =20 movel #sector_size, %d0 addw #1, %d4 subl %d4, %d0 - rts + data_exit: moveb #0x18, %a3@(write_mode0 - read_mark) - moveq #-1, %d0 rts --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12AE5442B06; Fri, 4 Sep 2026 09:33:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514416; cv=none; b=o1ZkY8hM87ePK8vuSp7nU9ayA9uup1Caq9Gkj6EAGsPOT7M/RQUXmSQFolPlGM8MLvEY4Gd13gBnBn1qKSKWoJmnSLfWbasd+NKPMzCXT7dA8Id3tFMsy0jWmf1H1sGP6N0sFs1SxUgbl93lTGao64VjfvTnVYQX2B2833Llm9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514416; c=relaxed/simple; bh=ei4bAlhk/mvOZzmuTTqI+R6yphimZOyPyFnV8JFrLLs=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=YUuGlZrZ7TxgW3LUF8v5unrBuOu0yF2kPSjt6IYdFmNqWzqNyFMsQQHd6AJyOykOkjWT+5LUtDuFFjDvEhsqZkd6GpyReamUuZKkHXf1avnrP8yzQRp0xkn88MokIX4GxLW9xdRKQUHTR8GiBZdJbKn/tOY+x1FIIdvhDAuoqVI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=RWhItfEs; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="RWhItfEs" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 3E908EC00A7; Fri, 4 Sep 2026 05:33:34 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Fri, 04 Sep 2026 05:33:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514414; x= 1788600814; bh=JeP79JHs0w/YH5LKkBWHZdiQJUzezgc3yjKNX3Xjfbg=; b=R WhItfEs4MDOZV+5dmr6dVorOjnD/Ni7OrHBEJHpY5tTzrNxmqsEkzptAaHcfnHqa vm/5vUNUk6Dtlq0icwsIWpFyVB5xEmLGEuju//9o6amMjEHduSBrdGYJLjJ/VROT MQTHmUa7hE+KmPnW0p3XJ/fuuMtcbsi4tZ8KiIzhI7mGeeg+bDF8O+eM6aoJJ/YK XQ5TCVss/wjsqSkKPHmhMb5YKf9J1PDF8waFCU0I+x1H+kyCdUye1JtH0kLVZiy9 BU7c7kqjKkPwN9OrBlzyVp8rUNL6Di1cZDKZ4aU01F/qBr+DGIjuJO2TxVxSnDbd NErSxZGZhUybzp1g00wHg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTE/Rtk6l3I9tqvKoBpTJTveLUphHYcAK1aitBUQpDNIkosRB8EZMISuuCMYAipC6D +/RTzVL2d8a+m6Bc5TLrlQP47Nx+3FOLDvdMZZODUHaNQCGx6Jl+5UqsvedKuq/7/WUY04 OmEz+pLiYAf9GcyLmpfzp0aVKrXxd+9inPzR5hoQc0Z3i9dss0KA+I7vBV2rZxbdxVflTp xLONIFohUrs/qTWq43lfJzhGtby2UyWXImtl6Q7ZHyI+A0TXzowQGCvI570zM+3ljALuqE 7N56HcamhyVJ6EIMvw6h3IZoA3f+em6U6oCLhwkvVheXLFnUHBZ2gdnuYSSZDXmPlOumn1 sw2w2YvRVIUBiZALeGC9znY5TFqZUtfl8y8+H5WHy2VkuqXi4n77/1lApc+Xv6jhaC1Y2q FDEdB5Beu00sx+/sYZhvkAokwOwV7T8/LQ9UPv6AkRnCLenPEF+dboTfMdAzupqXN/t/XJ NYmlIu1OhmR8FXX+tzQgMQDmw03htAHiOxtsCWje1r3atth2rKfwPDzYc4X+RX6/pFA1LP RJOAErthwRAXYdHy3XEI1dlORYHzt1OWq4QGS6Pk7ZUewEpCVeL0dlGis5mqyrSfnlqVbW 1duUoTtTUFzwaWg4WLY9zOBhyVAWimYHFf2YWiJNRB4Xwc4d+l4WvgC5sVLA X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:33:32 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <9bfcd0414192d1b95803c16701d62732ff6e8f3f.1788513997.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 14/33] swim: Check for CRC errors Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" After reading either the sector header or sector data, examine that flag in the handshake register which holds the result of the CRC calculation. CRC validation has to take place with the last byte still in the FIFO. This flag can't be checked by the caller because by then all bytes will have been retrieved from the FIFO. Return an error code when appropriate. Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson --- Changed since v1: - Load handshake register a second time because that's what MacOS does. Changed since v2: - Tidied up some hasty changes which appeared in v2. - Dropped reviewed-by tag due to unreviewed changes made since v1. --- drivers/block/swim_asm.S | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/block/swim_asm.S b/drivers/block/swim_asm.S index 31fc63b074dc..81c824923336 100644 --- a/drivers/block/swim_asm.S +++ b/drivers/block/swim_asm.S @@ -42,6 +42,8 @@ .equ max_retry, 40 .equ sector_size, 512 =20 + .equ .Lhr_crc_error, 0x02 + .global swim_read_sector_header swim_read_sector_header: link %a6, #0 @@ -134,6 +136,10 @@ crc1: tstb %a2@ =20 moveb %a3@, %a4@(o_crc1) =20 + moveb %a2@, %d5 + andb #.Lhr_crc_error, %d5 + bne signal_nonyb + tstb %a3@(read_error - read_mark) =20 moveq #0, %d0 @@ -224,6 +230,10 @@ data_crc1: =20 moveb %a3@, %d5 =20 + moveb %a2@, %d5 + andb #.Lhr_crc_error, %d5 + bne data_exit + tstb %a3@(read_error - read_mark) =20 /* return number of bytes read */ --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B45F440652; Fri, 4 Sep 2026 09:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514425; cv=none; b=tV7HbyaH5AScF8VC2SQzaYC/ST3KzShI4OxK7WKnLqZ+kjlASS0q0JEqOK4FBcixDezaguLtqijgL0ra+t/4u092+WN8lrOn5zjScBGi+v+HrZ5iw76N6ovr+pWfkq/CmM0p+2PArEjX0oTzLG0Jd3BD0k4AX+KqIGDfefWziJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514425; c=relaxed/simple; bh=4OYXX5SpESInibJI4MeslwBwhiXx63rU2H5QhopBD3s=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=sjJGB0oJHABORB9wk6MSX4YyKg3JWA8a4XELO7907cKZPfymOeGhNTzEcDpE9/b+MFozy/68BQHXGOJhZf5istHPLWPoAQhh/4uFfT6Rl7iX/7tGuP3ZXhwFRAj6d7VBiO6yx4YmxOVGZdPmuwnsGhWVX0GvyfdiRGo5wbK2aJc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=uMslS3Jm; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="uMslS3Jm" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id 74A4EEC00CE; Fri, 4 Sep 2026 05:33:43 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Fri, 04 Sep 2026 05:33:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514423; x= 1788600823; bh=QCHuIWCvGbUQzvcn6gYtNQdR8/7gekyyFIaPN78HB6k=; b=u MslS3JmouF5curpkNaW9Uo0pM5P/a4zHfsn+i2OWLxvtI7Rdi1R7nZywXAmqbizo Uks55TUgRxocndsrjK7j5DSdaEwyuKmJdBXUNB7gyO3hfJR66/kZInD2bpGe1AIT QwBG9rsOVxigrsBZmkt8LtCzcvpK0cK4CSq7+gaEJp4mriXTEaVQy+MuWpO2ReAK 0NcRLQ7lGe6vrLpncqjYSUFy30Jea1xbcGj7J0cRhBLuGmzwX3OJFqXRebExfo06 nrbw+j9VsEERjpDl8rCMPsWcEJYfqd2mLm9VV1j3FHA5RHZ2BrV5y0aNAUeltkg1 1nZQY+Z7QgEXxdeRNDuAg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEe+0K1AexRW5VKg6Igspc49h8df5hxyd+FQ2UxEzuyTDi2ZhdiSThGiBIwkdDgU9 3rC08hmhwBNxNoNuM+ycNNv31fkYVLn6pBr27tqKRLQMq1NV3DFc39Iqyivnkegn2UfxIv roQdqcH3VVXGJWlrRZqsrGKoS9rmBFYj7GFxW36+XXMnxcw5HiNtvMvRco3OYXN6UY/K0t SqGzE69/GT65xt5VU7CUtrbe1RJV9Of5WXGGzQneXN7Ylc6viWLtf2PMOfqRj9Ut2W6+Hz DfFSoa/BAnz3IHwFnQcu4acvCfz7MIdPrcCNMUsADy4T129cFo7Yojs7dtan6e38DtGhKx CHMxqjHvqVZbseXgody3wEkNfLA89naeRQlGa1Fwb7m0EJxWAr7ePz89Nuf/5R87ByIVEY fn6Mh2o20T+KO+isw/ciZ2vfYHuGKoa5qz7KXa138cMst88dUwq1OiX6USyI2LGzihGfN/ POxpesFjYQuCZYBiYiJz1ntmSnJn1MgdW6JTtM36ESYvk6SymsUwL4+WKU//KTFn79Dt/V CcVdi4KHw6+tERB7wtlJ/3Q026blZmqUhbpqWluXyRgx+iJlVBNt5KvJobXAwblTRwa+lc xKEd9JbVIj5nYgNykldGpULGlaHax7rG+W1HCKTlzvfzWBcbrFl8ooEaEcdA X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:33:41 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 15/33] swim: Check error register during sector read Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Clear the error register only once before a sector read operation. Don't clear it afterwards -- the caller needs it. Check the error register in swim_read_sector() and return the appropriate error when necessary. Fully validate the sector header. Don't terminate the search loop early just because an erroneous sector header showed up. Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 13 +++++++------ drivers/block/swim_asm.S | 8 -------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index cf5470cfd775..53a54a96feef 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -483,20 +483,21 @@ static inline int swim_read_sector(struct floppy_stat= e *fs, =20 local_irq_save(flags); for (i =3D 0; i < 36; i++) { - ret =3D swim_read_sector_header(base, &header); - if (!ret && (header.sector =3D=3D sector)) { + if (swim_read_sector_header(base, &header) || + swim_read(base, error) || header.track !=3D track || + header.side !=3D side || header.size !=3D 2) + continue; + if (header.sector =3D=3D sector) { /* found */ =20 ret =3D swim_read_sector_data(base, buffer); + if (swim_read(base, error)) + ret =3D -EIO; break; } } local_irq_restore(flags); =20 - if ((header.side !=3D side) || (header.track !=3D track) || - (header.sector !=3D sector)) - return 0; - return ret; } =20 diff --git a/drivers/block/swim_asm.S b/drivers/block/swim_asm.S index 81c824923336..fcf574ced85e 100644 --- a/drivers/block/swim_asm.S +++ b/drivers/block/swim_asm.S @@ -67,7 +67,6 @@ mfm_read_addrmark: movew #seek_time, %d2 =20 wait_header_init: - tstb %a3@(read_error - read_mark) moveb #0x18, %a3@(write_mode0 - read_mark) moveb #0x01, %a3@(write_mode1 - read_mark) moveb #0x01, %a3@(write_mode0 - read_mark) @@ -140,8 +139,6 @@ crc1: tstb %a2@ andb #.Lhr_crc_error, %d5 bne signal_nonyb =20 - tstb %a3@(read_error - read_mark) - moveq #0, %d0 signal_nonyb: moveb #0x18, %a3@(write_mode0 - read_mark) @@ -166,7 +163,6 @@ mfm_read_data: movew #seek_time, %d2 =20 wait_data_init: - tstb %a3@(read_error - read_mark) moveb #0x18, %a3@(write_mode0 - read_mark) moveb #0x01, %a3@(write_mode1 - read_mark) moveb #0x01, %a3@(write_mode0 - read_mark) @@ -191,8 +187,6 @@ wait_data_mark_byte: =20 /* read data */ =20 - tstb %a3@(read_error - read_mark) - movel #sector_size-1, %d4 /* sector size */ read_new_data: movew #max_retry, %d2 @@ -234,8 +228,6 @@ data_crc1: andb #.Lhr_crc_error, %d5 bne data_exit =20 - tstb %a3@(read_error - read_mark) - /* return number of bytes read */ =20 movel #sector_size, %d0 --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B91D6442FCE; Fri, 4 Sep 2026 09:33:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514434; cv=none; b=mWvzE/UDNEVzXi9bo12fTM+c1/SVO3ZKO2+C6ktTZWluHQegLZrjpCaXE5F7DFkSGbpq27Zr6OfzQ5y+Lsva29N8ns+Rgk3b293EVxPCCLeNrI5lmHAzHGqPTkO2vI3rPclEQr5Nt7yDizy0WLy3Q+TRjlWymbEW5Gb0w90/UV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514434; c=relaxed/simple; bh=OR02IR2Ki2iJIWbzJO/vB+3NKZMXfd/Zt1dhikSy54I=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=NxQQWzAuAAP98gLPRfFAoVLq9yqcT/tXYOzEKO6KTG19TAG4qqBimFJibvydp+sNoWdgJ/JOcX0HDWdbXU3F6XFoo4tLQqQGBC2NfnNpmzPemgljeq25/8tMShP3WNyqhSxZZQpVvDjrczpMOUr1MX7CvrTbH3d7Lavxjo/0ZIU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Jn3qWgHf; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Jn3qWgHf" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id C9096EC0128; Fri, 4 Sep 2026 05:33:51 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Fri, 04 Sep 2026 05:33:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514431; x= 1788600831; bh=eC0zbKKdmy8sFOzLUz32yPzDGFoZ/jh9E06NlaGHXVE=; b=J n3qWgHf55w2a2K8WwH3CN592Ho06hnqvZ7zck7CExfFK0QiKneEgX64O1q56XuV9 +44aFn2GT+ejvtxgBsfnyAterw30ScXmGiFvgjL5mtU1zdaQnM4oPT1LtbRPVeG+ GWShT5jecO4di2shtQhEjMAsa8vAfQTrT7kiHM7I+dsQIy8kzI2wEaIsSfPt9xTD cJSNIjzRxQRqYVBUNZqs3GWGIjUqM2fZFe6ydO4Y7/YQXoIyI+9suqMp81tV/02c Xq4kXW+I4OSMW5x2YmZVxrAROQ9mLbku5kc8Tc1Koi9UwBv0Y5BHS0RG/LPF66L5 9H2tUGYKZ59RUSVokB9tw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEH2qZt5RyVMGIjuBkUGlmhN5ZJte6hmKxUze7L1uOD8wVg4SMRrxTJ86lIDfqtkL +QxQRDVzf2U9TmIQ6RtPZMIwlvA7gRnX5BNqWd8IMTbr8gAZBs2pDrGigg2W0qRzrNb5Cp 7+bpE3THerIpIk7eJNCg621+gD7CzjDahrM0UG8DodY4HW+stGUYit3TjIW+xj1U8orIoK w2q1WP/Sx1+JLon679MHL/t6Dhlru/F6ofZ1XZZLdNU27UnoTb91jJA9rWObMTeLKoj14a 1H2Yi9N/48EiTFkgpEwgKk64rBUnCJYdWUOh1TPTm/JhyhFwQgTGlTbFDmXmqgotVKcHUU jvx58pwd7qK/bIJF67HSTGMgZWJKcZHWorZguPhDjt+pRULwyEnre8B+fBD2t7PfJWh2Fe eZCi6Llh+1tLk82vQSHOsieMjZODq9roBF8FFHCaqq9IUoa6vhEQ9PZP4VB4IRlEk/6JGz 0tUnm5eb/j80ZB1gVD2Y4lT/Lz2zjmourIf+9jj8xAxym5vcG7JZMHzEWcj5VeWlu6Rz5x Irvqbis4XnDkSxjUIrj5JGohRq4ej5BDFZuPGd76alZUXOnrkFzWI8GEMZDLeBGVgf/2sj 5/a0lMt+XqR1Q1iJC0U4o2VeF2SSABVo+b2w3PNLkH2zZ3VMUSWJcRmYZZmQ X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:33:50 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 16/33] swim: Don't use the mark register to read data Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If an unexpected mark byte were to be read from the data register, an error would be flagged. But no error gets flagged when such a byte is read from the mark register, which is misleading. Always use the data register except when a mark byte is expected. Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim_asm.S | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/block/swim_asm.S b/drivers/block/swim_asm.S index fcf574ced85e..699f7c90dd1c 100644 --- a/drivers/block/swim_asm.S +++ b/drivers/block/swim_asm.S @@ -47,11 +47,11 @@ .global swim_read_sector_header swim_read_sector_header: link %a6, #0 - moveml %d1-%d5/%a0-%a4,%sp@- + moveml %d1-%d5/%a0-%a5,%sp@- movel %a6@(0x0c), %a4 moveq #-1, %d0 bsr mfm_read_addrmark - moveml %sp@+, %d1-%d5/%a0-%a4 + moveml %sp@+, %d1-%d5/%a0-%a5 unlk %a6 rts =20 @@ -63,6 +63,7 @@ sector_data_mark: mfm_read_addrmark: movel %a6@(0x08), %a3 lea %a3@(read_handshake), %a2 + lea %a3@(read_data), %a5 lea %a3@(read_mark), %a3 movew #seek_time, %d2 =20 @@ -93,7 +94,7 @@ amark0: tstb %a2@ dbmi %d2, amark0 bpl signal_nonyb =20 - moveb %a3@, %a4@(o_track) + moveb %a5@, %a4@(o_track) =20 moveq #max_retry, %d2 =20 @@ -101,7 +102,7 @@ amark1: tstb %a2@ dbmi %d2, amark1 bpl signal_nonyb =20 - moveb %a3@, %a4@(o_side) + moveb %a5@, %a4@(o_side) =20 moveq #max_retry, %d2 =20 @@ -109,7 +110,7 @@ amark2: tstb %a2@ dbmi %d2, amark2 bpl signal_nonyb =20 - moveb %a3@, %a4@(o_sector) + moveb %a5@, %a4@(o_sector) =20 moveq #max_retry, %d2 =20 @@ -117,7 +118,7 @@ amark3: tstb %a2@ dbmi %d2, amark3 bpl signal_nonyb =20 - moveb %a3@, %a4@(o_size) + moveb %a5@, %a4@(o_size) =20 moveq #max_retry, %d2 =20 @@ -125,7 +126,7 @@ crc0: tstb %a2@ dbmi %d2, crc0 bpl signal_nonyb =20 - moveb %a3@, %a4@(o_crc0) + moveb %a5@, %a4@(o_crc0) =20 moveq #max_retry, %d2 =20 @@ -133,7 +134,7 @@ crc1: tstb %a2@ dbmi %d2, crc1 bpl signal_nonyb =20 - moveb %a3@, %a4@(o_crc1) + moveb %a5@, %a4@(o_crc1) =20 moveb %a2@, %d5 andb #.Lhr_crc_error, %d5 @@ -212,7 +213,7 @@ data_crc0: dbmi %d2, data_crc0 bpl data_exit =20 - moveb %a3@, %d5 + moveb %a5@, %d5 =20 moveq #max_retry, %d2 =20 @@ -222,7 +223,7 @@ data_crc1: dbmi %d2, data_crc1 bpl data_exit =20 - moveb %a3@, %d5 + moveb %a5@, %d5 =20 moveb %a2@, %d5 andb #.Lhr_crc_error, %d5 --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DBCE442FCE; Fri, 4 Sep 2026 09:34:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514443; cv=none; b=Q8UM3kBcUkk9ioSk04ti1VDUhGDe20xrhTGxBgDCj3i9XDi6L7c0MZGIcpB/vDFeFz/l6AtOBuS+4ewvYauGojh9kXwGDzHYsfLdSma7Tnm/PVxFHp29aYSaR9sZHw/KqPAcEICy2aw/lIfF+i1U+ul9ikX+lZ9y9GT7gHyYvO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514443; c=relaxed/simple; bh=k42Tk6MTlkTssMZgPfZFgNk1ma+plDP0aOeZ8315Bt0=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=qgJ68/HMoo91PaXGLU5KLyjl1Kg6Llovj5n4qjAdaIly0N3D+2mgAryCCsm5vTAT6k51msdjGqtRIpI6lHajk7o5yz9P72ss1Jdseo4OjAZtPdiXumdl4P6V0EloodzZYvArTA3E+l0VaKUOL98c8r278/d5bnKs+0f89G44Ys8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=t79qdFIA; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="t79qdFIA" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id 90FF8EC00E0; Fri, 4 Sep 2026 05:34:01 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Fri, 04 Sep 2026 05:34:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514441; x= 1788600841; bh=3/k6GW9Rf/OFdG6HQrf0fhr84k9b4329t4mbYPbl/fI=; b=t 79qdFIApJPStedp80wkwp768tMf4YIll8R2+nmRXX2TZz2mc1mkWeEwsosGXhnJo d8mTOFXT5RVwnpZrhEO+KyyFS3YyhIflE6QEf6UPfedS5PrXrFILM/DmFUGtgjSq 2B66SV39Gbnl54Gqnzkti4hj8lEDeMgxp6reG2J9HlTJ5XVAGSpDAvT6gTmjIxFT WDPJqkNjV5Ngby5Lrik0PUvxIz8Zg5DZpMKuPV/acvuuPzHwNdnMMlLy7mMvW/Gp xBWnwrdq8uTUsG+v+RNvqDpkbqaD7HhBXRciYS8rBDM2i8aFPiSteTyu2u7rTvi5 vPSy+6xsuKWhd8Kr8gMdg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTE/Rtk6l3I9tqvKoBpTJTveLUphHYcAK1aitBUQpDNIkosRB8EZMISuuCMYAipC6D +/RTzVL2d8a+m6Bc5TLrlQP47Nx+3FOLDvdMZZODUHaNQCGx6Jl+5UqsvedKuq/7/WUY04 OmEz+pLiYAf9GcyLmpfzp0aVKrXxd+9inPzR5hoQc0Z3i9dss0KA+I7vBV2rZxbdxVflTp xLONIFohUrs/qTWq43lfJzhGtby2UyWXImtl6Q7ZHyI+A0TXzowQGCvI570zM+3ljALuqE 7N56HcamhyVJ6EIMvw6h3IZoA3f+em6U6oCLhwkvVheXLFnUHBZ2gdnuYSSZDXmPlOummp LXmCop1wfWL43P0SZAFCGA9gCr6wc1W5qJKSCs+Kn8MbIGBUixrlX9RcDl1ccQPFxWR+zG MXTBghguvoC9Zm4lyxrY0s3S7slBYdFGiv40Km5faLxmBsmJPioE1+z1CpVfUIz1Y+wLhi CpAD+g1n7KaTuaUwTqhImGXEAe4FWjwq3C+U4jojZsajZPQbs0nCy8GXFXaSe+pFIqIshW p5GCLbxePCtUzayCcQgBC7Hbf3Q1JELArbbVvI0fmIrv2mz2PZA9v25FnAlSEYgUKAmmVm fRNY2uzuMf+dLRO0ZKkWgwa/SXfc7ufmKJiHF63Dh/8FWMyCrJXgYr4S/nYQ X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:33:59 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 17/33] swim: Fix buffer overflow Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The effect of this bug can be observed as swim_read_sector_data() inexplicably returning -5, or an error flag indicating that a mark byte was read from the data register, or other odd behviour. When copying bytes from the chip FIFO to the read buffer, the driver keeps count of the remaining buffer space using register %d4. A counter in register %d2 serves as a timeout. The driver polls (%a2), the handshake register, until flags indicate that byte(s) have arrived in the FIFO. movel #sector_size-1, %d4 read_new_data: movew #max_retry, %d2 read_data_loop: moveb %a2@, %d5 andb #0xc0, %d5 dbne %d2, read_data_loop beq data_exit moveb %a5@, %a4@+ andb #0x40, %d5 dbne %d4, read_new_data beq exit_loop Note that the exit_loop branch depends upon a flag in the handshake register and not on the remaining buffer space. Hence there may be no branch to exit_loop after %d4 is decremented to -1 (i.e. full buffer). moveb %a5@, %a4@+ dbra %d4, read_new_data exit_loop: Here is a second decrement of %d4 which can now reach -2. But the buffer bounds check is a comparison with -1, which is now ineffective. Hence the loop will continue copying until %d2 eventually reaches -1. Fix this bug by terminating the loop as soon as %d4 or %d2 reach -1. Reset the timeout whenever a byte is copied. Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson --- Changed since v1: - Avoid jumping to a redundant AND.B. - Avoid a second handshake register access when there's already a byte in the FIFO. Changed since v2: - Dropped reviewed-by tag due to unreviewed changes made since v1. --- drivers/block/swim_asm.S | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/block/swim_asm.S b/drivers/block/swim_asm.S index 699f7c90dd1c..e06aadb411a1 100644 --- a/drivers/block/swim_asm.S +++ b/drivers/block/swim_asm.S @@ -43,6 +43,8 @@ .equ sector_size, 512 =20 .equ .Lhr_crc_error, 0x02 + .equ .Lhr_fifo_2bytes, 0x40 + .equ .Lhr_fifo_1byte, 0x80 =20 .global swim_read_sector_header swim_read_sector_header: @@ -189,20 +191,20 @@ wait_data_mark_byte: /* read data */ =20 movel #sector_size-1, %d4 /* sector size */ -read_new_data: movew #max_retry, %d2 read_data_loop: moveb %a2@, %d5 - andb #0xc0, %d5 + andb #(.Lhr_fifo_1byte + .Lhr_fifo_2bytes), %d5 dbne %d2, read_data_loop beq data_exit + moveq #max_retry, %d2 moveb %a5@, %a4@+ - andb #0x40, %d5 - dbne %d4, read_new_data - beq exit_loop + dbra %d4, 1f + bra data_crc0 +1: andb #.Lhr_fifo_2bytes, %d5 + beq read_data_loop moveb %a5@, %a4@+ - dbra %d4, read_new_data -exit_loop: + dbra %d4, read_data_loop =20 /* read CRC */ =20 --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14CE244238A; Fri, 4 Sep 2026 09:34:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514451; cv=none; b=Bm9cfEW7l9htKuhzXBCalok/8/dNcQBzNMBLi/2JRgQYS+H4mIRPB6hGw+irZTLguskJT26gPLM833HBgSHC6kv2kYgrlXDDMhsCluRZXzbzTTYPhGGYMu0prchSnDRZObI6VKzZuI3/p2nVHHHDJCyH1SMypLQyNfkaj0ChA0Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514451; c=relaxed/simple; bh=M2U3egkupdhw8UFOtWia73vrryeA047adaHiCz27eLM=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=X0nUvPglsIpzhBs0lWDhdsJmZI0Cg5VvGgmTyFE1ibyqYil1ZYAOqDj21nZm84L2mg81iQVSaQ3Tmy8gEljLm8uzKnplML+kXmDtgYuk0+INvguEi607GjUr+SeZ2arAtQgDwlKKGHB1lVLXZ+itFpW6BGJHixrqIty9VrLftLo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=MojdG80f; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="MojdG80f" Received: from phl-compute-08.internal (phl-compute-08.internal [10.202.2.48]) by mailfhigh.phl.internal (Postfix) with ESMTP id 3D11014000B4; Fri, 4 Sep 2026 05:34:09 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-08.internal (MEProxy); Fri, 04 Sep 2026 05:34:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514449; x= 1788600849; bh=eKElv4anX41ZYrApDmg/UKkrc0G/g2ppT/AOlQikA5o=; b=M ojdG80fCWqQk7r3Jpj1Cc2IwzJkMq+yfcN8ZKXBxiPemLhbLIe4OLqcCHX7EHkWR jxGRRyTipQit7ZvxuIwrJZpjTt+P3NFdqltZ3m3yHYfrnHUGd5DyY+GHXOEnZugt q5Gc87GZIrgXW6DTDbv5iKbFRcPd2V2iexc7shImYU48s+sb1IamNdynns1wDsJ8 QXeavOEry3Zn2iDbBIBSIFl82pI3Ki7dMqsDR8olEcKXrZuFKg77Z9AYNejj2VZ1 J+gIHjUIHVxDkpmZkT68Ufgcv0HCaVapniYfQWZKZiTZvHrkAfkQO1/rAa9Juwc2 BT+4Da6kRnLFbHy5Q6/iw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFgppOi7PO95ZE0LnZQ1eC/b/6lLqxZnGp9DqtQ9Lo8yqgwEaqqt+SrMvXG86zMl7 8zj2bpNgo2LZUOH0SS23NVcO5EpAdufkCyfDnjWvzugrIG16R6Z8CTHYN3/cUrIjuOS6b6 LZQyqVShAdi54/+IxhSgEXw35axn23t/22GgInfNw3+fh5L8VQFUMRp6TNtAk3Q6dWkhI1 v+fUyHSYlKvUXOMhKLwkHtPgQiDd+jlDril2fPfXPa6NUI8nLwUJnnOFkRjaRLrsCodF1S 3GV4s1mXRW7/BclwSRGhCM1O1gF4gSbpfD4TjRpw76yLj1dLDFXoaiibgm79rB7Tj4qjfg 3H+/aagEURb3t2DnfCTbJuAgyDDW5z9G/mJ4mXOIMxz+db4um3h4tXDX6ozR/aAEYLMJ4C PHwOZDT2zoJ8ifIMbh/TLBcutL/9N1M91uKOH6w/fw/h0K4xd8f5bOv5zigj1rKRM8E5SQ N0NcUdlQd3oviXIS6SanNJVXW0aQN0SzrQGINobaUS9kZYzRoCynesxYn+eBHVA7xw8424 3156ImJqgtJheWDwHbLv1F2lEt8tCqeFk+w+zd0aQ+S0/VPHHm56fZlYhQKur1a76EpyrI oJI5Kdxyv15clN5i3FrLierKIRqKwJwLmriIYWNCuPliWth3TCV3qovcvf2Q X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:34:07 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org, Omar Sandoval Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 18/33] swim: Convert to blocking queue Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These drives are slow: completing a request can take hundreds of milliseconds. Delays are managed by disabling interrupts judiciously and sleeping opportunistically. As of commit e3896d77b702 ("swim: convert to blk-mq"), a spinlock is taken in irq mode as soon as a request is issued. That lock is held for the duration of the request. Hence the driver sleeps while holding the lock which is forbidden. Adopt BLK_MQ_F_BLOCKING and remove the spinlock. Use a mutex to serialize requests from the two request queues. (The chip cannot simultaneously process requests on both internal and external drive.) Cc: Omar Sandoval Fixes: e3896d77b702 ("swim: convert to blk-mq") Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 53a54a96feef..c3fbcf377d1f 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -211,7 +211,6 @@ enum head { =20 struct swim_priv { struct swim __iomem *base; - spinlock_t lock; int floppy_count; struct floppy_state unit[FD_MAX_UNIT]; }; @@ -537,12 +536,10 @@ static blk_status_t swim_queue_rq(struct blk_mq_hw_ct= x *hctx, const struct blk_mq_queue_data *bd) { struct floppy_state *fs =3D hctx->queue->queuedata; - struct swim_priv *swd =3D fs->swd; struct request *req =3D bd->rq; blk_status_t err; =20 - if (!spin_trylock_irq(&swd->lock)) - return BLK_STS_DEV_RESOURCE; + mutex_lock(&swim_mutex); =20 blk_mq_start_request(req); =20 @@ -560,7 +557,7 @@ static blk_status_t swim_queue_rq(struct blk_mq_hw_ctx = *hctx, =20 err =3D BLK_STS_OK; out: - spin_unlock_irq(&swd->lock); + mutex_unlock(&swim_mutex); return err; =20 } @@ -842,11 +839,9 @@ static int swim_floppy_init(struct platform_device *pd= ev) return -EBUSY; } =20 - spin_lock_init(&swd->lock); - for (drive =3D 0; drive < swd->floppy_count; drive++) { err =3D blk_mq_alloc_sq_tag_set(&swd->unit[drive].tag_set, - &swim_mq_ops, 2, 0); + &swim_mq_ops, 2, BLK_MQ_F_BLOCKING); if (err) goto exit_put_disks; =20 --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C20C44238A; Fri, 4 Sep 2026 09:34:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514462; cv=none; b=kzMnkx03xLhnqaBqH/fxLQP+/keQnv8sdjZkpXkHcgZFCKBwQmLYfkGEMlLSdSzK2p1VjUUPSQkIEiB6vT+VvrkteyDAe57UbWlxLHd98CJW8LVnTbMQ0NJpPwebx1PPhixF5+VrYQAg7PtDbzmhH8wmGZQBNcURkytSTtPNFo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514462; c=relaxed/simple; bh=1wZ85nY1Xb40yLRL1WgRJHMZba+zxtb61fsKP9HuagI=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=anHJ/SfmN2PIc/pPZodrM5uLGu6iRh2S/T/hw4kJQxCVHX1UvLeDKLvXNq+Omsd26VVWN+Et9HI2DMjwBthPpdqVxO0aqC5rheWgha9CKcboLLPC1EzfhyvTe/f2q9/WirPkf8ULSA/sSk6uatHw/S/aC4LzdtgrK693bRR5UQ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=UhGefoGx; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="UhGefoGx" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id BA042140009E; Fri, 4 Sep 2026 05:34:20 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Fri, 04 Sep 2026 05:34:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514460; x= 1788600860; bh=OgrKuJ8TfhNYprofHyiwoLzqrOniZxrU9W3RTA8FMaQ=; b=U hGefoGx0M7X/L/R8AwakmXLco2lYHRPlqA6sXhwGJgTESXxhyH7G1cn+x0XU3DPL ksCG314NbpVxch673k+44yB5TiOxmcgAnAzAo9RehXe7H45U4W9IBRBcZr3t6+Od bzDurWW8cidg7LGkvI2cfJWjmt2ywiS1Bd8fDvZRu2PUvfwn/+nMXeb5WKgwkZOm IJzkgHzcFtd99PCl+90nNxpTdXtwsZS8css86OTR2/DS/yDdJ076TFLa1zVzhgth 5SGZ1Cn0ntol+CfRKii7y7umOilLRu76XB/Xjky3pHKoypDRw5KjMdKPuyLXHBAV i32S1/VCVnao7sj1lOHwQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFZ/TtYWX7QRSPqbWdhFvGKPdYLqSrS0kW5tw/ccCSeQwGXLU8z8+n4MTGG5Fz3xO fBhPKm+HgWFmiq+gJDvSVIfRvZvgV672b0RABACnDdhJF/iW3opz+U3/SP3bVUvVx8Q287 Ap1gWmRx+bP8FRnMF0HKeE0yfsMRD8AYBXtaUsZs5aI7BW+fV7e9Q0YJu0hP5K8l60oxGK XrcuXNo1hSmleRjGCb9wMFpOFKoRGwYOR+2UyWTZOvcSmWg9D5Za0czKtKfTDaJ7RbQZgm lIJH+OOpA0D60VJW1h483ZeutJ4e8G1K0sL6VJD12jwsAudayvIunnWKGaY8cBa7nccFl4 dGRPIrPp6c/LFUbbk9AdFDSE4WRvUuWsfVOhrTdU6AJGIOPebqRLOnkqmR4ZIMSPPHRo9Y A9HSuXqNi2UYrB4vfY2H4WQGQSL5+AZZE4R5+1QFeqKO03uzL5bdr044STmLxGkF5kfbVC IVmpZ1Gf+bfqL5370CJFJ3oQULNZzANfdh62d7Lk8EKSr6xznZRgs2thtSgsCxsHUxiGB7 m+v4V/PG+7pkDdC8EgLWFX47PdNX0Oprmzt9JudmmKothO8aeRGTH52vTQafELU3RQN8j0 XizwNI333OiNIiWqGS1ggeb5mgd38X9p6vkKtGVaOvuhASNxi6bt6pvmIV/A X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:34:19 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <08ab67c2780c9107b87a1ece8b5f9cb54a8cea70.1788513997.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 19/33] swim: Remove redundant RELAX actions Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Wherever we have a swim_select() or swim_readbit() call there is an implicit RELAX. That means the caller doesn't have to do it. Remove the redundant code. BTW, Inside Macintosh says, "Be sure [...] that CA0 and CA1 are set high before changing SEL." Hence the RELAX found in swim_select(). The SwimIII driver in mkLinux also has that. But the swim3.c driver in Linux is odd: it scatters RELAX actions around as though SEL was not actually under its control... In anycase, swim.c really does control SEL so there's no need for that here. Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index c3fbcf377d1f..ea4663945505 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -336,7 +336,6 @@ static inline void swim_motor(struct swim __iomem *base, swim_action(base, MOTOR_ON); =20 for (i =3D 0; i < 2*HZ; i++) { - swim_select(base, RELAX); if (swim_readbit(base, MOTOR_ON)) break; set_current_state(TASK_INTERRUPTIBLE); @@ -344,7 +343,7 @@ static inline void swim_motor(struct swim __iomem *base, } } else if (action =3D=3D OFF) { swim_action(base, MOTOR_OFF); - swim_select(base, RELAX); + swim_write(base, phase, RELAX | PHASE_PIN_DIR); } } =20 @@ -355,13 +354,11 @@ static inline void swim_eject(struct swim __iomem *ba= se) swim_action(base, EJECT); =20 for (i =3D 0; i < 2*HZ; i++) { - swim_select(base, RELAX); if (!swim_readbit(base, DISK_IN)) break; set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(1); } - swim_select(base, RELAX); } =20 static inline void swim_head(struct swim __iomem *base, enum head head) @@ -385,7 +382,6 @@ static inline int swim_step(struct swim __iomem *base) set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(1); =20 - swim_select(base, RELAX); if (!swim_readbit(base, STEP)) return 0; } @@ -399,8 +395,6 @@ static inline int swim_track00(struct swim __iomem *bas= e) swim_action(base, SEEK_NEGATIVE); =20 for (try =3D 0; try < 100; try++) { - - swim_select(base, RELAX); msleep(3); =20 if (swim_readbit(base, TRACK_ZERO)) --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25B5C4457A6; Fri, 4 Sep 2026 09:34:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514473; cv=none; b=KEsBntAJXY93jjSjlxwmf50YmZde5WLixnPDRzyAfOMnashXfhuP48gcs0wogl1xcko9S0oBpWmcVMxYqSNslBoSR43AlCP86k07uvKyGhy/WXSC7Jh/axilABB8xzcvQUpSSXfiUPRj3yJefPwXr488iKJfIOV+DyAsL9ptb/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514473; c=relaxed/simple; bh=dO8QMILUhgA8Zfx+Xfz3sPDUvz/p9npfdmFjZGwc3Do=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=NP+E8bf1aP3Ot5ALxPaoU0A0VdZFMZdAI+zODBbT+l2RsiQ5gDVEth9AbEuua/yXrEAKyfWkrZ9DqFGRj76qatkdnmsVtlbEljDWa1jBw4m1HxxTyF8vT2mw6oWPkAFhn4Q2KbWosRUccm+FdKgZ92fEr8UUkAY3i9LBBeb5HSE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=QY5fWU5n; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="QY5fWU5n" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 5EB47EC016E; Fri, 4 Sep 2026 05:34:31 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Fri, 04 Sep 2026 05:34:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514471; x= 1788600871; bh=rkNIHvKMgEJtfrOYGBua/B72Sum6l4yyKQbdbImuNyM=; b=Q Y5fWU5n6KYTqU2wc6s9Kizd7F8f0TY6Yn9ENLTrwoU7hMMtOpQXOyz6UJgcTINCv z/CfXjoJvctIyfRw0ee2zYolt1JH1PQQ7YxP+HShDgcwk8W37s8PMckF4heRKv8l Zx5PMSVfRrxUP2SZeMrMUEAEnVqMmPCaPzJTGn5PFiDWGINBLJ+1AWY8Ma1b1z0f 5CR9GeTcivGeLESpZ3NGdvnWhRtk8ckMg2MmQBZLywEZilU1xFCCpJBvNagAv0c8 2jgI3dfX0Nlcl9stcJaNSrLM3w+hNHvbU9ukK/bZzLbyAuBwivvKcI1aCLSzKtzA SU+w9I+FkhXcXme3/KIvQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFZ/TtYWX7QRSPqbWdhFvGKPdYLqSrS0kW5tw/ccCSeQwGXLU8z8+n4MTGG5Fz3xO fBhPKm+HgWFmiq+gJDvSVIfRvZvgV672b0RABACnDdhJF/iW3opz+U3/SP3bVUvVx8Q287 Ap1gWmRx+bP8FRnMF0HKeE0yfsMRD8AYBXtaUsZs5aI7BW+fV7e9Q0YJu0hP5K8l60oxGK XrcuXNo1hSmleRjGCb9wMFpOFKoRGwYOR+2UyWTZOvcSmWg9D5Za0czKtKfTDaJ7RbQZgm lIJH+OOpA0D60VJW1h483ZeutJ4e8G1K0sL6VJD12jwsAudayvIunnWKGaY8cBa7nccFIz BaxXso6ACFmOH7A+7jeNeRS3VwPeCIl68212f2eVwLYW3oARrJDnfTg673wbMaO3pTWEJb mXq1p1XwYpfuQM2ADqW3g8XUkt3+USUbM7r6C6pGGq+Je2+l/oxv73Jv5T/wZcbCNqDAW/ zoTc3axXRG02gVo9TPjTl1fonIUr2w2zVlE35Clygc5s7ctFFY7ACoFItbvSVbzqYRLSxJ ynOQDFxmmA7nThsG4ky2OvtMOIeM4TxrbxaD14wFTY4TpCftvNQntGL8ogT12eD4VhmAZl ZLE6swUgxEjTvqIMoubqW5hDO7lSxvINlXwxQeR3S/UxRTJ7PVT5++9/sk6g X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:34:29 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <0ea2d3313dea26f8b4c2abc4d29055ac95aeb74b.1788513997.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 20/33] swim: Deduplicate polling loops Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Replace duplicated polling loops with poll_timeout_us(). Change the interruptible sleep to uninterruptible because signal delivery shouldn't be allowed to shorten delays required by the drive hardware. Change the timeout for the !STEP transition to 20 ms in accordance with the maximum interval required by the UPD72070 spec. The existing 1 second timeout is impractical considering the number of steps in a typical seek. Change the return type of swim_readbit() to bool because that way the bit names make sense i.e. the reader doesn't have to remember to invert the active-low logic used for drive signals. Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- Changed since v1: - Dropped swim_readbit_timeout_atomic() as it's no longer needed. --- drivers/block/swim.c | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index ea4663945505..59e00fb2bff5 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -296,7 +297,7 @@ static inline void swim_action(struct swim __iomem *bas= e, int action) local_irq_restore(flags); } =20 -static inline int swim_readbit(struct swim __iomem *base, int bit) +static inline bool swim_readbit(struct swim __iomem *base, int bit) { int stat; =20 @@ -309,6 +310,9 @@ static inline int swim_readbit(struct swim __iomem *bas= e, int bit) return (stat & SENSE) =3D=3D 0; } =20 +#define swim_readbit_timeout(base, bit, val, timeout_us) \ + poll_timeout_us(, swim_readbit(base, bit) =3D=3D val, 1000, timeout_us, f= alse) + static inline void swim_drive(struct swim __iomem *base, enum drive_location location) { @@ -331,16 +335,8 @@ static inline void swim_motor(struct swim __iomem *bas= e, enum motor_action action) { if (action =3D=3D ON) { - int i; - swim_action(base, MOTOR_ON); - - for (i =3D 0; i < 2*HZ; i++) { - if (swim_readbit(base, MOTOR_ON)) - break; - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + swim_readbit_timeout(base, MOTOR_ON, true, 2000 * 1000); } else if (action =3D=3D OFF) { swim_action(base, MOTOR_OFF); swim_write(base, phase, RELAX | PHASE_PIN_DIR); @@ -349,16 +345,8 @@ static inline void swim_motor(struct swim __iomem *bas= e, =20 static inline void swim_eject(struct swim __iomem *base) { - int i; - swim_action(base, EJECT); - - for (i =3D 0; i < 2*HZ; i++) { - if (!swim_readbit(base, DISK_IN)) - break; - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - } + swim_readbit_timeout(base, DISK_IN, false, 2000 * 1000); } =20 static inline void swim_head(struct swim __iomem *base, enum head head) @@ -373,19 +361,8 @@ static inline void swim_head(struct swim __iomem *base= , enum head head) =20 static inline int swim_step(struct swim __iomem *base) { - int wait; - swim_action(base, STEP); - - for (wait =3D 0; wait < HZ; wait++) { - - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(1); - - if (!swim_readbit(base, STEP)) - return 0; - } - return -1; + return swim_readbit_timeout(base, STEP, false, 20 * 1000); } =20 static inline int swim_track00(struct swim __iomem *base) --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31F9744A3EE; Fri, 4 Sep 2026 09:34:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514488; cv=none; b=pEQ3hpr2NWrJv+O1OnqYQqMUTrfWwbhx0i7DUAUbyp2s5BK3IaXOTZhLvVI256cwXUX3PH5AmfrDKextUFCMFW/9UqP3YdjKrKNoM4ajQeshq2EL1UFAhEXJxAN4JImR6GpinIRavH4iXcjCmay/Y+vT/D2gpuLW43RrLp8t7yM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514488; c=relaxed/simple; bh=3s4N1H9JRF/L4oKF87tQ0c56gXovHfXcU3/OPfUw8KY=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=Wa3735jaoKa8WddInvgUcy/ArJKOSMAbENMm2biOZaqf3ycfo0nYF0yv07/qArlv2+R438O3pmH1f1puZSyalSmA7HBhHlBThf+JHofGAJuNHRPeOds6ami/yseVXscJM+zuhHKFZ0I6U/RKCudWbyXsNyi0ZvcqacUomQkR4EY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=TlPdolnV; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="TlPdolnV" Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id 7870FEC0166; Fri, 4 Sep 2026 05:34:45 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Fri, 04 Sep 2026 05:34:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514485; x= 1788600885; bh=APzsWoatxbHr6Iwsqhvao1ZWjdttyfZm+IqhZmdpUv8=; b=T lPdolnVnsTNKkEL4RQq5kPdyjwK3u2aSNPmTkKk0iKel4c1I7Yvpe4+AHy3hR+/y b2m4+q/w9h2WYO+HCjU9RaSTaaGIIwjURU/mSSaFTrrYb568ab9XGs2Yyykva5BG rGAuerv0B8dXOFoHDVJr66pNX6SkxxRpi4y7Rwof+suIEjOpZ9ZsyR2iTJ4mjQIA yiwy7KexPinIKNv1mTC9+svFNtJCpl/ioL5ZEmf9Rtj2I73av+6Uyqq2A0LS1Nj3 x9tYomfqpvzn9LSgSQyP9mXXG65c2ab7531qx7HcY/m0aGTfzYMZLRlfZ3EeAsCF PR4Jgm+wy4pe29VZ/CQvw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEgSwz66V+qSU0onCxC1F8ShoiVzEkD4nv3k8arPvEJrRCttwK35Oooa03yDS3V7Z X24bDVU3zk97dZjGWhXiX/ncGofJJNeEuYKgl31r/eDK9q5L7nwuD3/hEQU4j57irJs8tO 84Cp9nRkKueV+P/Zh+1MA5C3iN5rv0++YXPj7VEh4HRI8ixbdKjZUIuiKKcqpAq6/i16Ze PQjCFsqYVbtDn7r5YuWGcGxoEjqVvREju6nRSm6O4BMaQ0J9b6++FaFcvgP73aZ6WigYRi RlMdiJjw76SzlSBX2alJJ3NXs6ywRX0EZbPP0m8cGOgA5DoC4o+kLwJIiLSJDXjG4wSOEc ImFxTNVrXEm79NTgOjLgrPsVLNZjhBCowpXTF+kbZlSSE+tBHbBvGrA+rkYyHA90Obm2l6 YJn2gGJ0hzltsCYopJpFf0+V0KRgIYjacCcRY1yMe2jwpo1wdQH7opCxAjk4+VC4ejuGVA KdzCHYt8MkPU67KH0Ql4NZqRACn4p8EfespEwP3YJspth60NEsn3iEfWxzR2J74EqJkbZb kLIeYrE7XPNsctWd2WE+7TQMaX69JTWODLMY23NR8GSZ7l7mIYL86EpudGbVufgKbKol+A ESbdS+TSFDsgT9jJGk4Zr7kYLPTZy+en5Ndw34EgspMNZmTRaWKvoRTmedlQ X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:34:43 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <8d6fc833c719de2248b64ee521418b1032b1e509.1788513997.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 21/33] swim: Check drive ready bit Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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 59e00fb2bff5..601ce79c96b2 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 =20 /* Bits in handshake register */ @@ -313,6 +313,14 @@ static inline bool swim_readbit(struct swim __iomem *b= ase, int bit) #define swim_readbit_timeout(base, bit, val, timeout_us) \ poll_timeout_us(, swim_readbit(base, bit) =3D=3D val, 1000, timeout_us, f= alse) =20 +#define swim_READY_timeout(base) \ +({ \ + int ret =3D 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) =20 static inline void swim_head(struct swim __iomem *base, enum head head) { - /* wait drive is ready */ - if (head =3D=3D UPPER_HEAD) swim_select(base, READ_DATA_1); else if (head =3D=3D LOWER_HEAD) @@ -387,20 +393,25 @@ static inline int swim_track00(struct swim __iomem *b= ase) =20 static inline int swim_seek(struct swim __iomem *base, int step) { - if (step =3D=3D 0) - return 0; - if (step < 0) { swim_action(base, SEEK_NEGATIVE); step =3D -step; - } else + } else if (step > 0) swim_action(base, SEEK_POSITIVE); =20 + swim_READY_timeout(base); + + if (step =3D=3D 0) + return 0; + for ( ; step > 0; step--) { if (swim_step(base)) return -1; } =20 + msleep(30); + swim_READY_timeout(base); + return 0; } =20 @@ -482,6 +493,8 @@ static blk_status_t floppy_read_sectors(struct floppy_s= tate *fs, =20 =20 swim_drive(base, fs->location); + swim_READY_timeout(base); + for (i =3D req_sector; i < req_sector + sectors_nb; i++) { int x; track =3D i / fs->secpercyl; @@ -602,6 +615,8 @@ static int floppy_open(struct gendisk *disk, blk_mode_t= mode) =20 swim_motor(base, ON); swim_action(base, SETMFM); + msleep(30); + swim_READY_timeout(base); =20 set_capacity(fs->disk, fs->total_secs); =20 --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D1EB45562F; Fri, 4 Sep 2026 09:34:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514498; cv=none; b=EIzsWtp3uSu9zB/AYdjvXYbl1lr4rtP7Hipc1Mr5ZUZLBxsodamywd13+dUB3YBGTcROSzEzNfFnwWZP28hVKZHNnw0mz1BO6gPw5VzZwd0i7eKs5ATGRXCmpHlCMVWJBozoDyZNN6Km5RzmMb7N4n/b8ZRU59EmkkJ62pHE4ns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514498; c=relaxed/simple; bh=5LKoyyv+B3JUSwHovTPFmmeF1GOl7dse2jfvawYntd8=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=lUGNAsvkF2+8Bs0KLT2nu6D12j606/5OcjLQnNmuh/M1lB6+GdQb0l+QbnWpnOJXeK7wce2OBB79eiTJMqUZcce4Ua5zMdWG+nOofiM8WE+Zb3+PNv4uIBLI5E/96XR9Y6kxYrItDtS4NwdZtWsTi27ulBRde1jfsa5DqBFVdes= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=DzMJLOjm; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="DzMJLOjm" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id A03A1140009E; Fri, 4 Sep 2026 05:34:55 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Fri, 04 Sep 2026 05:34:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514495; x= 1788600895; bh=RtsvlZUtERDJAcOg3qjdo4GY091HGFBTrei0xS7NPEk=; b=D zMJLOjmwhY89wnp0EUOXlIBhmGoCdezPlSYyO2XF/oUV9hBhtThmNnMWgr4ILCVW 2JPoUT55xshqG1BHF8WQ+mX+GZQHthojBkONbUZ0oIwx2Q3yvXPJV/KHuOJD8J4z pRG4QDcHlswe3YEyQ11rPfwuw83GW88lJHvmZ/mJRTlF+ABbBODFNjLvbjDlallM qhyWmlX/OeSqQzqGLe8+DqYuzO/mFhb9hHtoF+DRefI9iXMcn+wVJfByaSzHb312 /MkwzGq/8yVbOZDbRYU/pIwvIuC43wdNtePl7zkEa9yMaSk3s/bWmNqL2VCBLwIV 3bP60l9YUJhElrDeOhyiQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFwU+S4kdAMlQ0v/k0AIIWH8NEZGASJORdIHxKTKTXUZu4/+TuTqA94nuiEUMaRxS Gofh+bL92h8RMpG66xVFwu0W+p9wbh5ZRd08LqtVKnsUP/9Qrp2soVjzNROQy1equ47t7H GqReSb441wEtgq6NIY2eQSaFWVAevL8uK2VrYQsRbjCnFUu9sctSvc8HbwNcOZhBWEvrxc v4dU6ftgbUqTDUj8aqtOMM9o2mrrjTYuxdDT/c0DbswJjHoKR/5ejCxg8Y/5mjJMzYLbmT GHbOCAcx+v5nQg51GRLb73A1+7BY5hn9tVP95J29cL5TZcJG84qND/yu/wkLW77nvFWlln /yrDcq9sUVKrVReZ+mDfwadZxXbVsPisJ/byk1uJqDc1N1rAnoNUFszaMUIsmu1PvawqZb y7nZ11jAVGzgXodvt0Dg0OWp73jiwwiavcPYgmAjuQDti/00q0sxzvsBXde78Rp9e2e9sm kvIMayH45L35tV4ydiRFP/Bs+63wi05kdlXxT8T6vdUIRb17g3TQERQ+Uxv/OHbaCIjMpU PyIQlIsYe8mjicQKe/3XxYtj1p9AZZcr5Ul0I5gdGIS4i34vLyAJTHacm7o457hCW4U2uY LjPCyRZe26G20OExD5uKKIfKyLQZfl74gHEYb3zuPEFElTNSsi27w4McKmgA X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:34:53 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 22/33] swim: Revisit delays Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" AFAIK, timing requirements for the various FDHD drive mechanisms aren't well documented. But we do have the UPD72070 spec and secondary sources like swim3.c and mkLinux source code. This patch is needed to satisfy the requirements in the UPD72070 spec and follows mkLinux. Change the LSTRB pulse to 2 microseconds, because this is what mkLinux does. Inside Macintosh says, "Hold LSTRB high for at least one usec but not more than one msec". When a disk is ejected, pause before de-asserting /ENBL. Wait 150 us after the STEP command for valid signalling. Pause for 1 us after setting the step direction before sending the STEP command. Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 601ce79c96b2..a67ccd4504b7 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -290,7 +290,7 @@ static inline void swim_action(struct swim __iomem *bas= e, int action) swim_select(base, action); udelay(1); swim_write(base, phase, LSTRB | action | PHASE_PIN_DIR); - udelay(1); + udelay(2); swim_write(base, phase, action | PHASE_PIN_DIR); udelay(1); =20 @@ -337,6 +337,7 @@ static inline void swim_drive(struct swim __iomem *base, swim_write(base, mode0, EXTERNAL_DRIVE); swim_write(base, mode0, MOTON); } + udelay(1); } =20 static inline void swim_motor(struct swim __iomem *base, @@ -355,6 +356,7 @@ static inline void swim_eject(struct swim __iomem *base) { swim_action(base, EJECT); swim_readbit_timeout(base, DISK_IN, false, 2000 * 1000); + msleep(1); } =20 static inline void swim_head(struct swim __iomem *base, enum head head) @@ -368,6 +370,7 @@ static inline void swim_head(struct swim __iomem *base,= enum head head) static inline int swim_step(struct swim __iomem *base) { swim_action(base, STEP); + udelay(150); return swim_readbit_timeout(base, STEP, false, 20 * 1000); } =20 @@ -398,6 +401,7 @@ static inline int swim_seek(struct swim __iomem *base, = int step) step =3D -step; } else if (step > 0) swim_action(base, SEEK_POSITIVE); + udelay(1); =20 swim_READY_timeout(base); =20 --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7461C443AA8; Fri, 4 Sep 2026 09:35:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514511; cv=none; b=H/AyfYdmfbrx1bJ/ZSorMoQHrE40OeTE1c0I48NrIm0FRts2buRf/N6vk98sN1EbJEzAe0tIoufsGdYrpZ7TdYIV0//dFLvmGEJMMX0P38Z4KNgmD02hvg3RoaW8Gp1dRebEXwyv/x8/RKddn9dUOTtSR9WqsDBFaNResKXOwQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514511; c=relaxed/simple; bh=VKUoMlUUTM7260szLHaRYLxLOMjF1geleJ6OkdjJmmk=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=YJRHMXbXmiruIl1KYPaeVL35n3C+/1zfJrkp7KhDuZJQqlAfzdfVO0SiXuzBfLTe/wjPeNKbOqzC8hN+j2qB3hqRc3vr9RGnKaNiR3nrpt0vUtNswlJJ4UB2kBB7tvHOWw7kyDFeeUYWqp70aFAiV1UHrCgQDumiD0GRUyIHkWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=e/SMOmL9; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="e/SMOmL9" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id AD07214000B7; Fri, 4 Sep 2026 05:35:09 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Fri, 04 Sep 2026 05:35:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514509; x= 1788600909; bh=pQLrz/ACQ7lA3/uYHUfM3yuICJ2vi3NVBe7zO3B88y0=; b=e /SMOmL9KXsx6dtU/b/RFc0OcvnDGQsDMb+O34Gj0Pnar5uJjdlMn9aaU9jx0tkaT x/C91SSaBAISbtAUJa+El2BlcyEutcx7kcds4wUEAbzhjYntqgQv7m9vum7aOSYW GlTnbbPQ629R8C359Gf2sBtJ1XpMvmYtYw8FWBG3meiujkVtby0jp2zzSUZGrzMN e0bHgwRhs27oZpD+NPauT2B/ErU23iJ5sgoDvotXtKZQt79U3gHyj9QjIeJVoO9J igoSgi0IRSp2IWtcj+k6mG/MA4XydbNOnVT2aX1ts1ALTDza8/z87G3i7hnKKnCg lRH6Jq/dxeLuNtDAD+r0Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEgSwz66V+qSU0onCxC1F8ShoiVzEkD4nv3k8arPvEJrRCttwK35Oooa03yDS3V7Z X24bDVU3zk97dZjGWhXiX/ncGofJJNeEuYKgl31r/eDK9q5L7nwuD3/hEQU4j57irJs8tO 84Cp9nRkKueV+P/Zh+1MA5C3iN5rv0++YXPj7VEh4HRI8ixbdKjZUIuiKKcqpAq6/i16Ze PQjCFsqYVbtDn7r5YuWGcGxoEjqVvREju6nRSm6O4BMaQ0J9b6++FaFcvgP73aZ6WigYRi RlMdiJjw76SzlSBX2alJJ3NXs6ywRX0EZbPP0m8cGOgA5DoC4o+kLwJIiLSJDXjG4wSOTh NSoUr2pmqeELn0ju9SGsWSeiCKfDHLgRf8sUJfx+p2FIbgPXHgV2IEbLaK+jPZcQT4j9gK iy62hQ/e3Bzxau11hqVz3GdPe3j+B7qVgmBfoctLUnb6Ku1ltpkjbF9MzLS2Z5Om2GC2gl 5IPWMZoyBooZRZt23ua2XA2uDpdGjNbXDAwzGNBiR08fOpxvZDTMBHmBXh5GVWNqflG8Ow WBk5nIsHatkW77dKx9WZDBgeuwa5nuFzO2p5Yr5KR0i+YldVTYlyrUiOBokppdQez7TH/R uQtEWL9ucSni21D7b8NvoLt8D5/SGfo+6S/ylkxvg+7hTR5hBOaXglcYEILQ X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:35:08 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 23/33] swim: Remove pointless mode0 register write Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This write has no effect so remove it. (If side =3D=3D 0 then no mode bit g= ets cleared. If side =3D=3D 1 then mode bit 0 gets cleared but that's pointless because that bit is already clear here.) Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index a67ccd4504b7..9bfda4b07ba9 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -464,7 +464,6 @@ static inline int swim_read_sector(struct floppy_state = *fs, =20 swim_track(fs, track); swim_head(base, side); - swim_write(base, mode0, side); =20 local_irq_save(flags); for (i =3D 0; i < 36; i++) { --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 068434457B7; Fri, 4 Sep 2026 09:35:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514525; cv=none; b=nG+/zo6HDI0JlX7r6pBjFxuxWgEGo2lJxxDEhDZYzin/RLtZGy6gBR0AS3XhwEhSbasjTVlo4LoVX0KS4aB8UokqDB6b3k5Zv8fYN9WXeoASMNos6BXUV+FneQy3ZVe7n8QAD2xki6r9Y89e940i5iTcampHhHQj4sR2UJLSmb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514525; c=relaxed/simple; bh=QtlXqpEs40Gx0zhBD5P+C6OV/WvfbVGFK8YipoEWUF8=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=tYFSRLqDMh3pr2tx/CcYPiYjz/wqJlxtbWUxGpyl17MIRUwO0wr4YV3kvfRVYie/4T+DK37h4NOlTR+VH2R2P9j/CO/hJ+aHzOtvPSCBYYQFMU47yeq7Le8ptkupkRWOeAFV5WMQBw17HJgjV/aKW53sqGyLmCCIL/91hjpF1PI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=sgw/oVb+; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="sgw/oVb+" Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.phl.internal (Postfix) with ESMTP id 0D85CEC0195; Fri, 4 Sep 2026 05:35:23 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Fri, 04 Sep 2026 05:35:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514522; x= 1788600922; bh=pzf8Qzh6OOrpTQYpzT3PZyzI8Y2lS32XCjDQuYjY91g=; b=s gw/oVb+BxkeH5/pOMrYTWH59TCLgRprhIrc1ML5ndgyuH6b5O1OZB4dg0V3P22Cv kGgTnUFKEOOOivhuM2vtsTp5xRpe8mjPO4R7Dtv8nqV2q9zIksXn1ky2BAkOUYgq pdvFdAR3mF3E4K9VJ/CKcCmthPjLT0RT4013O41t7vqD2+5MmsPGCpAnvjO9Wpe0 6UBjvk0szugAFQecXHE7gXwN0nXgvmH8rhgHSFUgEiboUeY2SVrfecQTXhlU6KF/ /NxPCuPjTwpsfS+Xee7Fa0IdlcRfhoPhChHvXa5R3DwvmFgI7H8BCiL3X7uDW2Ra v6G4oll6GQ9q/MQAn5dZQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTES4bQ21oAzpNnp51xfFHSMQBPKtrMCV5iYYMBFJYMMGuku2wDZqHLDhf7MMkpQep sMe4CyNnIEY4dUJg6qGIApiDz7xq7NkSCScmKgrMc4345BLDBaaFf6c8TLqowSoQSjBNao tQAjHxJbuqzVv3VzZRZEacp4FA41Q9OcL5NDtbJMFMDUCcPGJR7zU6OainbhxZYK3NU11B Fa2x5PyGrJHtwPQxOc1oyHJXrbM2nyqpGGOSM3yceNTB7ODw+A07JKEQZT40T9t1sfxdOY Z+GEWRwgrC3pQuxmclLHPwxPnQJ8sX9Nh9G6tEyIm0Ldv+rMccWy5ZFRy0U8vBhf8uuzM2 iqBHWc+uytA7yiE1aAPvhIklNaTpbrN3BHuGDYwqSHmKcQUFLc/ziuR1j+H0sqYFu4Z51D ljbU2otf1srST9dKXyFd4AvNPQhxvClcyImBUY5evKMEzeJGY9hAXAh1QcH+Boq3vwe+Ei R/fTk++tfq8IuZWhQ66OdTTI7IiqYyvgJ543t7fti3IXZQva4fZqemxlcJ/0YeHlSPKINy PnKQxi5eW9LGlWMpHTEgtM9DGXWU0os4hIePnEWVHpwbXBOJ0njEpLIZtOysNiUgFmusET zFyJ+E6IcUnLeq1DVp+OVxPVXcj5GOxXIxx//PgofvBW9m3uNYQiVT2M795A X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:35:20 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 24/33] swim: Don't needlessly re-read sectors Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" floppy_read_sectors() is confusing because the `track' variable seems to conflate tracks and cylinders. Rename this variable, eliminate a division operation and adopt suitable integer types. For readahead to work effectively, small sequential reads should not require waiting for spindle rotation. Unfortunately, the present algorithm is very inefficient and does a lot of unnecessary waiting. E.g. if the device is asked to read sectors 1 thru 16, and if sector 9 happens to be under the heads, the driver will proceed to read sectors 9 thru 18, but discard the results, while it waits for sector 1 to arrive. If sector 1 couldn't be read on the first attempt and needs a retry, the driver will proceed to read sectors 2 thru 18, but discard the results, while it waits for sector 1 to come around again. In between reading sector 1 and sector 2, the driver needlessly calls swim_track() and swim_head() again. But what's worse is re-enabling interrupts after each sector, because on a 68030 system this can result in a full rotation between sectors (which would be a 200 ms wait). Floppy drivers usually implement a track cache that can be filled in a single rotation to solve such problems. But I think there is a simpler solution. After stepping the heads, use a sector bitmap to record sectors that were successfully read from the present track. Read (or retry, if need be) the requested sectors in whatever sequence they become available. Keep interrupts disabled until the whole track has passed under the read head. swim_read_sector() assumes that it can search a whole track by reading a fixed number of sector headers (essentially, fs->secpertrack) but this assumes no false sector headers are matched in the sector contents. To prevent that, call swim_read_sector_data() unconditionally after any valid sector header is matched. Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson --- Changed since v1: - Use GENMASK() macro. - Use fs->secpertrack instead of hard-coding the high-density value. - Don't use a failure counter. - Use unsigned integers where appropriate. - Call swim_read_sector_data() whenever swim_read_sector_header() is successful. A NULL pointer is passed to indicate that no data is to be copied into the buffer. Changed since v2: - Loop for fs->secpertrack + 1 iterations because the gap search will match the index gap as well as every sector gap. - Reinstate the failure counter because that way interrupts aren't disabled for too long when a medium error is encountered. - Improved commit log text. --- drivers/block/swim.c | 99 ++++++++++++++++++++++------------------ drivers/block/swim_asm.S | 12 ++++- 2 files changed, 65 insertions(+), 46 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 9bfda4b07ba9..637810d86e37 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -180,9 +180,9 @@ struct floppy_state { enum media_type type; int write_protected; =20 - int total_secs; - int secpercyl; - int secpertrack; + unsigned int total_secs; + unsigned int secpercyl; + unsigned int secpertrack; =20 /* in-use information */ =20 @@ -452,68 +452,79 @@ static int floppy_eject(struct floppy_state *fs) return 0; } =20 -static inline int swim_read_sector(struct floppy_state *fs, - int side, int track, - int sector, unsigned char *buffer) +static unsigned int swim_read_sector_range(struct floppy_state *fs, + unsigned int side, unsigned int track, + unsigned int start, unsigned int count, + unsigned char *buffer) { struct swim __iomem *base =3D fs->swd->base; unsigned long flags; struct sector_header header; - int ret =3D -1; - short i; + unsigned int i, bits =3D 0; =20 - swim_track(fs, track); - swim_head(base, side); + if (count > 0) { + count =3D min(count, fs->secpertrack); + bits =3D GENMASK(count - 1, 0); + } =20 local_irq_save(flags); - for (i =3D 0; i < 36; i++) { - if (swim_read_sector_header(base, &header) || - swim_read(base, error) || header.track !=3D track || - header.side !=3D side || header.size !=3D 2) - continue; - if (header.sector =3D=3D sector) { - /* found */ - - ret =3D swim_read_sector_data(base, buffer); - if (swim_read(base, error)) - ret =3D -EIO; + for (i =3D 0; i < fs->secpertrack + 1; i++) { + if (bits =3D=3D 0) /* All sectors were read ok */ break; + + if (swim_read_sector_header(base, &header) =3D=3D 0 && + swim_read(base, error) =3D=3D 0) { + unsigned int offset =3D header.sector - start; + unsigned char *buf =3D NULL; + int len; + + if (header.track =3D=3D track && header.side =3D=3D side && + header.size =3D=3D 2 && header.sector >=3D start && + header.sector < start + count && + (bits & BIT(offset))) + buf =3D buffer + 512 * offset; + len =3D swim_read_sector_data(base, buf); + if (swim_read(base, error) =3D=3D 0 && buf && len =3D=3D 512) + bits &=3D ~BIT(offset); } } local_irq_restore(flags); =20 - return ret; + return bits ? ffs(bits) - 1 : count; /* No. of contiguous ok sectors */ } =20 static blk_status_t floppy_read_sectors(struct floppy_state *fs, - int req_sector, int sectors_nb, - unsigned char *buffer) + unsigned int req_sector, + unsigned int sectors_nb, + unsigned char *buffer) { struct swim __iomem *base =3D fs->swd->base; - int ret; - int side, track, sector; - int i, try; - + unsigned int try =3D 0; =20 swim_drive(base, fs->location); swim_READY_timeout(base); =20 - for (i =3D req_sector; i < req_sector + sectors_nb; i++) { - int x; - track =3D i / fs->secpercyl; - x =3D i % fs->secpercyl; - side =3D x / fs->secpertrack; - sector =3D x % fs->secpertrack + 1; - - try =3D 5; - do { - ret =3D swim_read_sector(fs, side, track, sector, - buffer); - if (try-- =3D=3D 0) - return BLK_STS_IOERR; - } while (ret !=3D 512); - - buffer +=3D ret; + while (sectors_nb) { + unsigned int cyl, x, head, sector, n, n_ok; + + cyl =3D req_sector / fs->secpercyl; + x =3D req_sector % fs->secpercyl; + head =3D (x >=3D fs->secpertrack) ? 1 : 0; + sector =3D x % fs->secpertrack; + n =3D min(sectors_nb, fs->secpertrack - sector); + + swim_track(fs, cyl); + swim_head(base, head); + + n_ok =3D swim_read_sector_range(fs, head, cyl, sector + 1, n, buffer); + if (n_ok =3D=3D n) + try =3D 0; + else if (++try >=3D 5) + return BLK_STS_IOERR; + + buffer +=3D 512 * n_ok; + sectors_nb -=3D n_ok; + req_sector +=3D n_ok; } =20 return 0; diff --git a/drivers/block/swim_asm.S b/drivers/block/swim_asm.S index e06aadb411a1..73d5ced1abe3 100644 --- a/drivers/block/swim_asm.S +++ b/drivers/block/swim_asm.S @@ -198,12 +198,14 @@ read_data_loop: dbne %d2, read_data_loop beq data_exit moveq #max_retry, %d2 - moveb %a5@, %a4@+ + moveb %a5@, %d3 + bsr .Lmaybe_store dbra %d4, 1f bra data_crc0 1: andb #.Lhr_fifo_2bytes, %d5 beq read_data_loop - moveb %a5@, %a4@+ + moveb %a5@, %d3 + bsr .Lmaybe_store dbra %d4, read_data_loop =20 /* read CRC */ @@ -240,3 +242,9 @@ data_crc1: data_exit: moveb #0x18, %a3@(write_mode0 - read_mark) rts + +.Lmaybe_store: + tstl %a4 + beq 9f + moveb %d3, %a4@+ +9: rts --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7961C442B23; Fri, 4 Sep 2026 09:35:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514535; cv=none; b=m/IF3appzQZW+nCC6vDjfvhRlOqwioT443o8TD8+syxJNWdlbCxXUeT/QJ73Yrvt6LOW/v/SuKDHVN5zaUEuX05u/coQbcxN4J9faaHwJ69s+C74mXkpqamO88/Qn72FLRiz/lQvcx/f7KKaIMiYVkwWYNy2Hl9iLJ8nP8ewK7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514535; c=relaxed/simple; bh=FVv8MuAOVa/siSFGcZALAEpqHf+wpAWHaXLRjoPbDYw=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=n/Uo+elBLobPbk7f2/UR9638cL6SiJsmrpk8xvExn6yvjYoHXkerAdBZwuncfPuhK7uo5Tj1FtsDjs6bkDfsAbRwcolBGGgph8GlMuBtQ0ISCXbuequo3P5wp/LK23ARhsRB21y9uTetAtMHnxqtOUhh+u4XMOcqQBiqRxd470s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=c9x8ZOyv; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="c9x8ZOyv" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id 98179EC0195; Fri, 4 Sep 2026 05:35:32 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Fri, 04 Sep 2026 05:35:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514532; x= 1788600932; bh=JE0iFEaDh3BOMKgrYEkNtZofOa8oDEbLKuZlxvRlVNQ=; b=c 9x8ZOyv0I4jwBD94kbdvBCfLntepu4fZPUc0Pq6hsN8RydJcog0MhYnC3beurA+F SZwqiw5qRy5G8p8ir39PToXSdHVf2TfAu+2KtvkfMaQHx0VGq8QZi+nXqu74EzCV aBu+IzTbyPO2BCMb7nPreeUXVqvUY0U7fOadXxFCZv+BzPHoh3OGsWZ2LiFQ8H1T QvdqXeyuj6WAvfPjUk3+D56PmlR5Ym/N6b2T7XMEVZckG+3VY+gADpVdtsIJwyVq q7j0nRrSZ7NlVP5092ADWpLAum8tmsD0tdAg6PxGlUBVVT+Vcost271SDOumRXH5 E2sbkOvA1VgRH0z/alliw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFhdXECWRYw3tVnCHePo/zYY4j+SuKUMgx56WEOg7qs2HvwD7oQucaotLGfMUi33o hHC1FeDfKnZlrGeiVT5Mqj2UUIPon0Gt5+731VYDwOvjgTrP7e/NeimjpJFjueb4IrDvAr +pOYqyhHNLMPTSUFxcsFks9onV/NJ5Li73uXKQqsCWOwh15/PCfntwYAWO6qxWE4//IIji NXIbET797+0vRU6iZolh0J1ljXWBPxs9DJdtAnGbTYyaGB2RK4T0pkOkMLz9iNZPu981Se KVCYoyZiCUf1f50VzPbl3H6+Bi6lZQNpv+anj8bDUR38j6YWwDvcULGU7FSQ92mlG+5FDB MRcEpxLDwZ9Immus/sLlKJZT9PSbZLkk1qsREGaLktKpMuNwNpb51CBHF9QDIOSgOSw9nY F0IkEbxaEr0FGqTJPXFMW3fxMDj5YS0I2rU/uVApTKZfFTpS6k5orCwVIFRCgxwk56NEIV o9fus5184ydtRy9K9ejKQlc7v1QsqJ4zfZeJ14q2guu5796WSptaqTXo1gtngnse2CBlSY 80kLViOPmMin98vF2FpfF0PE+8WWu0lcIZPRUEi1sYFPNITASfstn3OgVrE2u4rHQT6vTF dyTX67hE7IlEWHuD81qGk/H/U+RZbdxaNc3cde7s2V/pyQghqJrO4URZ59HQ X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:35:30 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 25/33] swim: Don't search beyond the first data mark Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The ISM chip does an automatic MFM gap/sync search when the Action bit is first set. That search may stop at any of a) post-index gap, b) address field gap or c) data field gap. To find the next sector header, the driver need not search at all. It only has to validate the mark bytes. Once the sector address mark has been validated, swim_read_sector_data() is called to read the sector contents. Between the sector address and data fields lies an intra-sector gap followed by a data field mark. After this mark is validated, the 512-byte data area is read into the IO request buffer. Problem is, if any byte in the data field mark is mis-read, the driver searches the whole sector and then reaches the data field mark in the following sector. The wrong sector is then read into the buffer, and swim_read_sector_data() returns success. The request is silently corrupted. The existing limit on polling loop iterations does constrain the search distance but is inherently tied to CPU speed. This is probably the reason why corruption was only observed on a 68030 system. Discontinue the mark search when the mark bytes fail validation. Fixes: 8852ecd97488 ("m68k: mac - Add SWIM floppy support") Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim_asm.S | 73 ++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/drivers/block/swim_asm.S b/drivers/block/swim_asm.S index 73d5ced1abe3..241088b12829 100644 --- a/drivers/block/swim_asm.S +++ b/drivers/block/swim_asm.S @@ -41,18 +41,45 @@ .equ seek_time, 30000 .equ max_retry, 40 .equ sector_size, 512 + .equ .Lmark_sequence_len, 4 =20 .equ .Lhr_crc_error, 0x02 .equ .Lhr_fifo_2bytes, 0x40 .equ .Lhr_fifo_1byte, 0x80 =20 +.Lmfm_mark_check: + /* + * This subroutine reads and validates a mark byte sequence. + * On entry, %a1 and %d4 shall hold the location and length (resp.) + * of the mark byte array. + * %a2 and %a3 shall hold the locations of the handshake and mark + * registers. + * Returns zero in %d1 for success. + */ + + moveq #-1, %d1 + subq #1, %d4 + movew #seek_time, %d2 + +5: tstb %a2@ + dbmi %d2, 5b + bpl 6f + + moveb %a3@, %d3 + cmpb %a1@+, %d3 + dbne %d4, 5b + bne 6f + + moveq #0, %d1 +6: rts + .global swim_read_sector_header swim_read_sector_header: link %a6, #0 moveml %d1-%d5/%a0-%a5,%sp@- movel %a6@(0x0c), %a4 moveq #-1, %d0 - bsr mfm_read_addrmark + bsr .Lmfm_read_header moveml %sp@+, %d1-%d5/%a0-%a5 unlk %a6 rts @@ -62,33 +89,25 @@ sector_address_mark: sector_data_mark: .byte 0xa1, 0xa1, 0xa1, 0xfb =20 -mfm_read_addrmark: +.Lmfm_read_header: movel %a6@(0x08), %a3 lea %a3@(read_handshake), %a2 lea %a3@(read_data), %a5 lea %a3@(read_mark), %a3 - movew #seek_time, %d2 =20 -wait_header_init: moveb #0x18, %a3@(write_mode0 - read_mark) moveb #0x01, %a3@(write_mode1 - read_mark) moveb #0x01, %a3@(write_mode0 - read_mark) tstb %a3@(read_error - read_mark) moveb #0x08, %a3@(write_mode1 - read_mark) =20 - lea sector_address_mark, %a0 - moveq #3, %d1 - -wait_addr_mark_byte: - - tstb %a2@ - dbmi %d2, wait_addr_mark_byte - bpl signal_nonyb + lea sector_address_mark, %a1 + moveq #.Lmark_sequence_len, %d4 + bsr .Lmfm_mark_check + tstl %d1 + bne signal_nonyb =20 - moveb %a3@, %d3 - cmpb %a0@+, %d3 - dbne %d1, wait_addr_mark_byte - bne wait_header_init + /* read header */ =20 moveq #max_retry, %d2 =20 @@ -163,30 +182,18 @@ mfm_read_data: lea %a3@(read_handshake), %a2 lea %a3@(read_data), %a5 lea %a3@(read_mark), %a3 - movew #seek_time, %d2 =20 -wait_data_init: moveb #0x18, %a3@(write_mode0 - read_mark) moveb #0x01, %a3@(write_mode1 - read_mark) moveb #0x01, %a3@(write_mode0 - read_mark) tstb %a3@(read_error - read_mark) moveb #0x08, %a3@(write_mode1 - read_mark) =20 - lea sector_data_mark, %a0 - moveq #3, %d1 - - /* wait data address mark */ - -wait_data_mark_byte: - - tstb %a2@ - dbmi %d2, wait_data_mark_byte - bpl data_exit - - moveb %a3@, %d3 - cmpb %a0@+, %d3 - dbne %d1, wait_data_mark_byte - bne wait_data_init + lea sector_data_mark, %a1 + moveq #.Lmark_sequence_len, %d4 + bsr .Lmfm_mark_check + tstl %d1 + bne data_exit =20 /* read data */ =20 --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 453AF442B23; Fri, 4 Sep 2026 09:35:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514545; cv=none; b=V4E1wTGO8L971mxB2q7RwOQ0RPPjztFhp1EegZ4A09zDt/0ZS+IswCxXGfEeFGgkzoJu7HkOdjMV9FlUFIseYUIiGlpgyTZ9iBMUD0KlYZ/54eo9HeQPTvZsbO4lKxNbebPMDOLhK9IPNbVrKS90KMJXspPQsEjIN/Wm0Le0H8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514545; c=relaxed/simple; bh=Sjt4m/UwSDY9zaOMplN1GOQKXrsxPrspeHxixk9NV8Y=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=jPWT7WADI4jiFxAAenm24DkgnHijdQKB0kZ/GvD8QqvwltaMK77KCEBrBQVkz3H7SITl4ri841yVLTzeZG8Nk1fiGzVS5aK1d68VISv4xiehLX99U8bUQYciNH7+tdETqVyGkCFFfqYAd41kbMiOrxMwu4a9m+Jx0gl9V4D2T1w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=d1Wg04Un; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="d1Wg04Un" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id A1AA0EC018E; Fri, 4 Sep 2026 05:35:43 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Fri, 04 Sep 2026 05:35:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514543; x= 1788600943; bh=vY4d4m5al/ak4Pc98Pi7L/0wx0/i3VzkrzE9scLyi+Q=; b=d 1Wg04UnqYh8Nmu86Ew/lrJGgwUzLIhvT1khJw06aLufGNChGFtXuUvoJbRBG7kC7 McIBHlinPRiYfJc/8U45IWrPS0zer8Mte/0qnVWvZv62rsYSrPFbTEXPx+iCnZE4 V9lEJahL3FqIYrwe8+VGUg6iS8jHrzjFbznnUB6I0MjVJfWeCM3Pj9vZe+kMz+Nr vh+LZLwWwCtfzYl8Qkpru9GFAUW1CQTh6Bf8MgYy915AsHty85GrvVEjR9rFMXjQ XVM5VR/CyC4TXjU+9MRBSpI6zWnHsVS+zUk990yf8yQW5IZAzerV7taK+Y8Dbrlq kDIVJzALOI064+filtqPA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTF1sA8Xp5SQpLKPpl7AOr0OCI6a5muovCjMEclTQyynzEcS3CRdTjaZz8PU8K7WR7 lfQ3mDP7gXeanu8WmFTTNTNg/WI3tmXduWuLwEtqkTz5KfwhqzwioviZErMgjDZWxH58hL ih/8BC4Od4xW5ClBg2Setyl1uFZbuKpueRv4UkSy93ie3kcU6K9mH8wt6e98EXVurgHAvD MBDOw+EcwXx7T/tslfs+d2j7oiGrIytLxYYyT1iUYG4q6gimgwbZjGKP0TSVgw26FCz7SL lg+B/dQvzS+oOmxLOh6t9JfYFKVOoBcMAeQr36ZU0zAxhgEHVdZcTZoA90wPHeyf1527uI I2ZtggWjDk4YhaoaOrvoBL1NELDEVARX8hVTT8/A1S596QPsIu0M3IcHcTjTslam831nK3 DzxiFvvzttH3AZpWn2ncnc11LLBZi0NlUchHzy6SuTLWx0oib0vvMdBQS3HiCssZGzqubU ejb/Nfgzl9MSu9Jl+Ipy7dd3Sd0/zFcAVvt7WPL5rIZZuxFWJiDmCashjXop45Yayt+MzV Ip8QWpKjC4GqQU0gPo5CNDAHgolLUN+ENnGglGrmlOwZC2tNFUl5YKgg7HdqeoIaxJUqbe yF/qBE3X5ieTAha/BKsglnpSnNhD3xUjdUGhA9wGthd6XHXuZ6GSZ9uXFwgw X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:35:41 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 26/33] swim: Remove pointless specifiers Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If the compiler made these functions "as fast as possible" that wouldn't actually help because they involve slow mechanical operations. Remove pointless inline function specifiers. Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 637810d86e37..3ce73176da2e 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -222,7 +222,7 @@ extern int swim_read_sector_data(struct swim __iomem *b= ase, unsigned char *data); =20 static DEFINE_MUTEX(swim_mutex); -static inline void set_swim_mode(struct swim __iomem *base, int enable) +static void set_swim_mode(struct swim __iomem *base, int enable) { struct iwm __iomem *iwm_base =3D (struct iwm __iomem *)base; unsigned long flags; @@ -250,7 +250,7 @@ static inline void set_swim_mode(struct swim __iomem *b= ase, int enable) local_irq_restore(flags); } =20 -static inline int get_swim_mode(struct swim __iomem *base) +static int get_swim_mode(struct swim __iomem *base) { unsigned long flags; =20 @@ -321,7 +321,7 @@ static inline bool swim_readbit(struct swim __iomem *ba= se, int bit) ret; \ }) =20 -static inline void swim_drive(struct swim __iomem *base, +static void swim_drive(struct swim __iomem *base, enum drive_location location) { if (location =3D=3D INTERNAL_DRIVE) { @@ -340,8 +340,8 @@ static inline void swim_drive(struct swim __iomem *base, udelay(1); } =20 -static inline void swim_motor(struct swim __iomem *base, - enum motor_action action) +static void swim_motor(struct swim __iomem *base, + enum motor_action action) { if (action =3D=3D ON) { swim_action(base, MOTOR_ON); @@ -352,7 +352,7 @@ static inline void swim_motor(struct swim __iomem *base, } } =20 -static inline void swim_eject(struct swim __iomem *base) +static void swim_eject(struct swim __iomem *base) { swim_action(base, EJECT); swim_readbit_timeout(base, DISK_IN, false, 2000 * 1000); @@ -367,14 +367,14 @@ static inline void swim_head(struct swim __iomem *bas= e, enum head head) swim_select(base, READ_DATA_0); } =20 -static inline int swim_step(struct swim __iomem *base) +static int swim_step(struct swim __iomem *base) { swim_action(base, STEP); udelay(150); return swim_readbit_timeout(base, STEP, false, 20 * 1000); } =20 -static inline int swim_track00(struct swim __iomem *base) +static int swim_track00(struct swim __iomem *base) { int try; =20 @@ -394,7 +394,7 @@ static inline int swim_track00(struct swim __iomem *bas= e) return -1; } =20 -static inline int swim_seek(struct swim __iomem *base, int step) +static int swim_seek(struct swim __iomem *base, int step) { if (step < 0) { swim_action(base, SEEK_NEGATIVE); @@ -419,7 +419,7 @@ static inline int swim_seek(struct swim __iomem *base, = int step) return 0; } =20 -static inline int swim_track(struct floppy_state *fs, int track) +static int swim_track(struct floppy_state *fs, int track) { struct swim __iomem *base =3D fs->swd->base; int ret; --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBA49442FDF; Fri, 4 Sep 2026 09:35:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514558; cv=none; b=FPGO6/zSrqVaBchHt61sUIt89zwdJBgUe2EbMC+gn7ZGnzEpf/BzdrhTS59FIcZBhssv7Bx2mpLa51HC3LAqeALDFvUe+a8nEjhU3kD5jXJNn+vQ26G3464oBysCtLgjQbNeeZNH1v+JNgHID463mHdw8BM+CjwOA8aaLPq8ock= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514558; c=relaxed/simple; bh=54s669xz9R4knQSDFIxGY95Jbs1iNwq26b5KurojJus=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=asRU9jTLjg01ETdn/OA1esPq0iXVIeHa2+ANBTrxTY+Jm9YZocLb7RZBBc7XoAC+y03XukFA/xtAto497Mfkq1N9qz9Zhh1VZ+F9eUN5t7XDQwlOqutJ63gSFMy4bQ8JYQy3dzY7zlwqay/zkpSq2wsrWr6Gf/kuhCbEhGQrHJA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=ojDBP+D0; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ojDBP+D0" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id CBA6FEC01CD; Fri, 4 Sep 2026 05:35:55 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Fri, 04 Sep 2026 05:35:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514555; x= 1788600955; bh=kMa4KjbYmjabaIB7zCkIhmIco0mIOh9GB0j7GmK0U+4=; b=o jDBP+D0HzaKWgBbiITJ0ncR1ADpbu/gXumY2HzwzpGbgR+vVbyeADF2RYaveGh6M EiKLtDzaEX21My9ileXh8OyR+rPMdq3wk41u2OIEVTeZzjIo1vX944n9IOE8qo0v e+muCCFLQGMK+7LeKj6FEzGpQKIeNSQyy9OQM7z18Vi7TBr9nXvdj6wRc9iRKX31 ZqSg9wuSe/i6IxgxLU4Z0or6HdCxw0QoHTjMm6vNYJ+rxq07j+l6BPW4ClF6lCng rTgUclA9c9P3oVH7/wZLA5p+KlRHBmYDd8iwlS/fjj7J/fOqiDwaFmJNYSsx0Xr1 lwGrdXDEMaDeYFFOd2uOg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEgSwz66V+qSU0onCxC1F8ShoiVzEkD4nv3k8arPvEJrRCttwK35Oooa03yDS3V7Z X24bDVU3zk97dZjGWhXiX/ncGofJJNeEuYKgl31r/eDK9q5L7nwuD3/hEQU4j57irJs8tO 84Cp9nRkKueV+P/Zh+1MA5C3iN5rv0++YXPj7VEh4HRI8ixbdKjZUIuiKKcqpAq6/i16Ze PQjCFsqYVbtDn7r5YuWGcGxoEjqVvREju6nRSm6O4BMaQ0J9b6++FaFcvgP73aZ6WigYRi RlMdiJjw76SzlSBX2alJJ3NXs6ywRX0EZbPP0m8cGOgA5DoC4o+kLwJIiLSJDXjG4wSOWd BGUbTFruA+0pFCU8Tb0J7j06EvzYhq5c0S+S7D/wSSH/sXYelGRtHPbcEV3kMV00hQ2qxX 7PV4m7V6HqRDzRnfMqKOsoDh7+rgAA3hmn+dN0lSTD4SlfvraKTmUiiwuhQNIMEtQ5YJOi xM9h2ymqVtOGbnDZPCpdW9oyGpUt5vJmb+X+WSZmELU09W7nFKS9TaVsYR8ZbzBhiNB0B4 qrAVxnhVc61LBH+lOpP7em5J3O3PkMkHr7qo4ND2+IqvVp0julfc9CXxfscYc8+kVX94jh YJEhEFSmISBG9rxLMceGXq8MHbZ3TLZZF+Jh27HSRzLQAZUu2rl/uM1r1bCA X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:35:54 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <613fa64bc857fecd141b5049eb9188ed72c9ec52.1788513997.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 27/33] swim: Move swd initialization Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For better readability, initialize the swd backpointer along with the other floppy_state struct members. No functional change. Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 3ce73176da2e..f249b96339d8 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -764,6 +764,7 @@ static void swim_add_floppy(struct swim_priv *swd, enum= drive_location location) if (swim_track00(base)) goto out; =20 + fs->swd =3D swd; fs->location =3D location; =20 fs->type =3D HD_MEDIA; @@ -853,8 +854,6 @@ static int swim_floppy_init(struct platform_device *pde= v) err =3D PTR_ERR(swd->unit[drive].disk); goto exit_put_disks; } - - swd->unit[drive].swd =3D swd; } =20 for (drive =3D 0; drive < swd->floppy_count; drive++) { --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F5BB44AB7C; Fri, 4 Sep 2026 09:36:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514568; cv=none; b=WuvGiBZBxYX6fhxFkrFO5+PeIVmpwqokWcDPU7JDAZzlJkmAl1rRB395jvSKfNWYi7x/2jfmTaiWdpf3UC4exqMsodpZlpwCLZIpVwlAI853QPptAfJTdV4EK15W4911H4Lm4YV+ygpEDo65fj9pF5XOdGjgr7wjSnxLLNrCPMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514568; c=relaxed/simple; bh=2fO1Nem8psV2BkjGVjYicEG3JCcCuYnNeeWE91GQ7rU=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=M+jC3mACRkIlWaG13SX7kfcmNDtXa1aUOBTc9j23z2jiu5CLl9S20A9JlLHgchWaMQqqpGiA5ktEvdSrEiBNgzLUxTi9alzR7FnuOmX5G98ZikRmT9W7DWA2BLEn40oYkC6gBsiw1dfxXopHaElP0OhlFaLul1xDCjJn1OeUq2M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=iVSu3bD2; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="iVSu3bD2" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 87174EC01F3; Fri, 4 Sep 2026 05:36:05 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Fri, 04 Sep 2026 05:36:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514565; x= 1788600965; bh=Tho79OsiO2FJWFdgFU+2neNMuP7dJTkpAAbGMDaxns4=; b=i VSu3bD2lLSQAPfqtO/7+wNjjzQNNyFTKz2tQwQNrLfTu3yLkVz0h+rWHn3XvCkEG 1f8qAAnW5nlzHOoKsklOLeSvpsNS47tVvGfbW87iYZfvKKo9EppjuUNCTwLRtQum f34411Sxk3mv9kkkvQo1v9wb3NzmzKCt0vsMgTnk9OLk/3BCLCnCDNdtbimMdHZs ZtfKBymkrGXaw1Kwr7g31np6ILWlK0eAadO9ECk7fUGONRJ2nfQrJYhZ0f3ewXPh bKcmWK+lAJqOFmYty+OpmYYD8aVEAAg6cLChz5p26wCmWKXgChbQctw7Hwlew0EK YO1CuCzvMAi/hCK998SoA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTG2k577uDIDfm5jzfBdETCuanfOTnt5vT+Axih7bVvGSgJDBPpJ+GL/LXsHcgEpZ4 RC5KHYugI5UaHe6JFYpb4bXBM0FxyLRXOp/X9d5ZOg2Ly58fUO0/OmbwN5cHbLu9sehiqM h9MCdGCEJIsgdXf7qX9gR0srfmKNBjWG3Pz0rJGyFDbc7ny0QDgWCsea9K/QVXVwC+WQn1 /WeYxYu0ujQ+4f7Q6s/BX5WsAHenyiVIakVPqBf8IDrqgnLyqGQRmDhTpKk+gBytK587fb RwBpCQY2ZiVruSNCs9KFw8IIZZm1rG9teq5nrbmN6dPQfYZgmVhHgDAJ7hJABVwoGYNPlm +3r5vSHxFe5gJ8HuHqY7TnykzX9qYUTISmY30td35xU5S1ME1R7UKyrL0ivYxnss+/r0MF 3PkDzy5ZllCqCJUKrfshDV/o9he0cauH9FO1LE7Jh6P+ABWEpKLxO30O2TmQmlglJJ2pUW EUTTL1x5TCjuO4GCAzBBweH394Zv7cCsQrVfDppKNWwQCC07lhq1c0AO/yyzALe0kfAe8x atQfAMA4GVzAmHvDaefxvfMN+72N7SURd0OQVouO1ALhR/RrCYbJ54DDi6MmmgFo/6d0pg /UZVVbTkcCBAnrnesIQHbxIhXVP4HGweU/Bs45SyWBYEhbE2FCXlLTLGvFFw X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:36:03 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <082b79a3f2fa2ff5df9b51c582e01a8e47444613.1788513997.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 28/33] swim: Add some helpful references Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These documents relate to the IWM, ISM, SWIM 1, 2, 3 and associated disk drives. No functional change. Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index f249b96339d8..3b8acaa21787 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -8,6 +8,14 @@ * based on SWIM3 driver (c) Paul Mackerras, 1996 * based on netBSD IWM driver (c) 1997, 1998 Hauke Fath. * + * See also: + * Inside Macintosh, vol. III, ch. 2 + * https://archive.org/details/SWIMDesignDocs + * NEC uPD72070 FDC datasheet + * mkLinux source file swimiiicommonhal.c + * http://www.mac.linux-m68k.org/devel/iwm.php.html + * MAME source file sonydriv.cpp + * * 2004-08-21 (lv) - Initial implementation * 2008-10-30 (lv) - Port to 2.6 */ --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FBED468C23; Fri, 4 Sep 2026 09:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514576; cv=none; b=IcuvNfsaZojvU2zNSAgrsB+w28WKlxaGo7ELrGzZ83Yxym7ojlrM7BXaYZqCRLPUrdZw6CRny6UzEwIO3Awx2on5RBLiYnE+ckDgnkzFVIyHtwYO3NKSsOwKcfelM3ndtKSDTbqJ/gIuxrCwWSHqRP4W8T9aXVfz6xsjQ2zKTmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514576; c=relaxed/simple; bh=E30q6xWkz3SJ09FtFyDQILssqBaKUrJXbdFpdnoB58w=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=ayVByXfGVMeCCwhnlhRilRPsjhJiUWW8ICRxIYa8PT5TtlJ/poIUGdl8V/MyAaguM22iwGDG/v1jJ6H5bYtl9KkisoJQWfSgiOxaTs0PkCAr91qgcmAD/eZ5AvW96S6W7FLsCp7fdU+OrZ0V7+sjY6rCRc/Kq6ZKKQh9HohW0DA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=nojY0jcj; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nojY0jcj" Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.phl.internal (Postfix) with ESMTP id 5ED90EC01A2; Fri, 4 Sep 2026 05:36:13 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Fri, 04 Sep 2026 05:36:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514573; x= 1788600973; bh=u0KCUaZRNaA4dmF8L78r6ujqfisMQB5TBvF5SJrRSUg=; b=n ojY0jcj6L9kiTjXsw8vKSgEm/s0QRmNlTdcXvoZ3NqMCZE9h+SHrqHs8nLBz4Toz 7E5KlHeZTeNYoYRNoAscUqFTgaXW2HcKRck5W14WAbxE2mL6TKYCDpcRYEkGcMMc B+VRKWJo9NtmYsZxZzmXmVdOqXobH5YJJI6RDzM/1ni/A0ojd4OVnWmyY3qGrBWD 7xsm1N5hyktWAhhhVWdt0Vwpj032ZtMNHwy0KvHzabzr09US11N1k1oWBW89i/zL 9lMuZ0+NrOEmY9b4CZfl22kVdKNAA2DBpnThoPL8cz3zVnwxMcguyJL0P69D66/K w1c7FRInx4vS8mFgymTgQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTF1sA8Xp5SQpLKPpl7AOr0OCI6a5muovCjMEclTQyynzEcS3CRdTjaZz8PU8K7WR7 lfQ3mDP7gXeanu8WmFTTNTNg/WI3tmXduWuLwEtqkTz5KfwhqzwioviZErMgjDZWxH58hL ih/8BC4Od4xW5ClBg2Setyl1uFZbuKpueRv4UkSy93ie3kcU6K9mH8wt6e98EXVurgHAvD MBDOw+EcwXx7T/tslfs+d2j7oiGrIytLxYYyT1iUYG4q6gimgwbZjGKP0TSVgw26FCz7SL lg+B/dQvzS+oOmxLOh6t9JfYFKVOoBcMAeQr36ZU0zAxhgEHVdZcTZoA90wPHeyf1527oF k3OyW34Dht9CgzQ3Oo87BQ+mqNn5f7fALyySpRLchR8UAyRkwFTR+A/gaW6SqAql8kldI6 zKAIdess88t3sEAk7xxQoyc7W5dpyMkamvVKql6CqGqN9nfnXvvCO5IrZN3PLF10vBBEh+ g4Y7T7tNrvcrzrdSFaAY73UIyggkO2HbE/5pNEHzLkBp0VY36ohaA2F6+CPjARhN5mSd83 yLIfxkAaT2PF9JkhQO84KnsZjyUE3zHls+v10H5SHPZP5NhpZzwBQgNxmv4laLNlEzymQ7 8zh5JX7YEqlpMjTSsi5BxKsIzpvpjVehZV88KQZFDdny7Uo1H+XSVjRfIU6Q X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:36:11 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 29/33] swim: Remove unused macro definitions Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Also remove the horizontal rule at the end of the macro definitions as it doesn't any add value, IMO. Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 3b8acaa21787..1501444fe070 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -130,25 +130,14 @@ struct iwm { =20 /* Bits in handshake register */ =20 -#define MARK_BYTE 0x01 -#define CRC_ZERO 0x02 -#define RDDATA 0x04 #define SENSE 0x08 -#define MOTEN 0x10 -#define ERROR 0x20 #define DAT2BYTE 0x40 #define DAT1BYTE 0x80 =20 /* bits in setup register */ =20 -#define S_INV_WDATA 0x01 -#define S_3_5_SELECT 0x02 -#define S_GCR 0x04 #define S_FCLK_DIV2 0x08 -#define S_ERROR_CORR 0x10 #define S_IBM_DRIVE 0x20 -#define S_GCR_WRITE 0x40 -#define S_TIMEOUT 0x80 =20 /* bits in mode register */ =20 @@ -157,12 +146,9 @@ struct iwm { #define ENBL2 0x04 #define ACTION 0x08 #define WRITE_MODE 0x10 -#define HEDSEL 0x20 #define ISM_SELECT 0x40 #define MOTON 0x80 =20 -/*------------------------------------------------------------------------= ----*/ - enum drive_location { NO_DRIVE =3D 0, INTERNAL_DRIVE =3D BIT(1), --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B057B4477F5; Fri, 4 Sep 2026 09:36:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514586; cv=none; b=UcnKSvpeDrUIASuDlzc+RbUoB362PATB3+LERda2xSUP9ScQ+ldPpC/pmn2+lwXPdHpoz9vDSFuC1dL+s8NX2SJ+JsPHDjUSeXuPTfESlLDiXKg7SjMHOC+RBOSRW5DHAgwCjLMcpVWHuSOV2OHxkgEfh3EdhOXi1WXD06NeiIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514586; c=relaxed/simple; bh=KBXKxt6P0G5kYd3DMM5it9aUm8Y6FcNbZ50G8muC2AM=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=fsXBwzcGWgSEth0hq2VgW8Fd0ktIYTDntE0EgcQMWWN3YGqUsWtBeycbjQ/5XAUGCsIBUjo914MffDe7gGPN5a05NTRLbrMdK2vfO1FULi3yVLVajPdhcyEoICBBys0KK7k/cZ/CMh+nvShiMYcw6z0Io/w990PX1qlGqHUgASU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=HGhUXsGR; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="HGhUXsGR" Received: from phl-compute-07.internal (phl-compute-07.internal [10.202.2.47]) by mailfhigh.phl.internal (Postfix) with ESMTP id 92FB814000B7; Fri, 4 Sep 2026 05:36:23 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-07.internal (MEProxy); Fri, 04 Sep 2026 05:36:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514583; x= 1788600983; bh=hrRgqAeah4TNWLlkx6lLt/cNMnqAA85FE9HMuJS0LZs=; b=H GhUXsGRFMNXfU7eih37baWP2deB0oUrWCdp0MqiWl04VUp6ZfA2xPnLALxv9bSvW m5wsc4egok5ruIQeZsQzTxicEvTw5gPI9FQvphERGVc89wQ+d+vk+252Ubh/rFyL MqIyhXgSssJRNisMj3Iu1Egg5KUCHY0Gae76oN5MXpkBzxxYho0VrqEBC0BmYmHg vUPPwhFbei4Xn4/rbxJrtcm9d1Nz6oXtCLpSa4fz/iE1BJIbMdgmn8m8eMOSeCUq gI+kovZdNmZyFSCT7dyKsnck4+lD8a12n1dhTNllmcBcnuBRGMXvPZsk4wDygySw BTKvq1km/FnzEq36RH7+w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEe+0K1AexRW5VKg6Igspc49h8df5hxyd+FQ2UxEzuyTDi2ZhdiSThGiBIwkdDgU9 3rC08hmhwBNxNoNuM+ycNNv31fkYVLn6pBr27tqKRLQMq1NV3DFc39Iqyivnkegn2UfxIv roQdqcH3VVXGJWlrRZqsrGKoS9rmBFYj7GFxW36+XXMnxcw5HiNtvMvRco3OYXN6UY/K0t SqGzE69/GT65xt5VU7CUtrbe1RJV9Of5WXGGzQneXN7Ylc6viWLtf2PMOfqRj9Ut2W6+Hz DfFSoa/BAnz3IHwFnQcu4acvCfz7MIdPrcCNMUsADy4T129cFo7Yojs7dtan6e38DtGhSs 7UQpvgPBN2FcrZsm83Tk911BeeLF3EYIYBEOlh+EFXYf4BMXjhOzTAaogfXDPFwYlWlb1I S6SQ+PmI7GOtMeJd6jifMigYUPYOOlbvs/f/BXADu4KLeezuNVEXh4zReeOLDxbvvtmMCz MANm38k9ZemtQodT62zEdBAEAOYr+Uxwrm+DZq3X7Sx5B5au0x++D8CzrnzDhS0jENCfnh hL/AAvzIqbGOgU+2reQs507wBQQzRQUFbujSNoKag1LYj90Pp69qq643gmg77BwadZavoB +p6Qhwi5MtidPbnrfQYdu45VJhA5ZMqMtHwUyBaxLVDB5oHnkU2gKq4pSfpg X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:36:21 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 30/33] swim: Clean up whitespace Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" No functional changes. Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 46 +++++++++++++++++++++------------------- drivers/block/swim_asm.S | 14 +++--------- 2 files changed, 27 insertions(+), 33 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index 1501444fe070..a5be31b732b5 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -2,7 +2,7 @@ /* * Driver for SWIM (Sander Woz Integrated Machine) floppy controller * - * Copyright (C) 2004,2008 Laurent Vivier + * Copyright (C) 2004, 2008 Laurent Vivier * * based on Alastair Bridgewater SWIM analysis, 2001 * based on SWIM3 driver (c) Paul Mackerras, 1996 @@ -69,7 +69,7 @@ struct swim { REG(read_handshake) } __attribute__((packed)); =20 -#define swim_write(base, reg, v) out_8(&(base)->write_##reg, (v)) +#define swim_write(base, reg, v) out_8(&(base)->write_##reg, (v)) #define swim_read(base, reg) in_8(&(base)->read_##reg) =20 /* IWM registers */ @@ -93,7 +93,7 @@ struct iwm { REG(q7H) } __attribute__((packed)); =20 -#define iwm_write(base, reg, v) out_8(&(base)->reg, (v)) +#define iwm_write(base, reg, v) out_8(&(base)->reg, (v)) #define iwm_read(base, reg) in_8(&(base)->reg) =20 /* Bits in phase register */ @@ -165,23 +165,23 @@ struct floppy_state { /* physical properties */ =20 enum drive_location location; /* internal or external drive */ - int head_number; /* single- or double-sided drive */ + int head_number; /* single- or double-sided drive */ =20 /* media */ =20 - int disk_in; - int ejected; - enum media_type type; - int write_protected; + int disk_in; + int ejected; + enum media_type type; + int write_protected; =20 - unsigned int total_secs; - unsigned int secpercyl; - unsigned int secpertrack; + unsigned int total_secs; + unsigned int secpercyl; + unsigned int secpertrack; =20 /* in-use information */ =20 - int track; - int ref_count; + int track; + int ref_count; bool registered; =20 struct gendisk *disk; @@ -216,6 +216,7 @@ extern int swim_read_sector_data(struct swim __iomem *b= ase, unsigned char *data); =20 static DEFINE_MUTEX(swim_mutex); + static void set_swim_mode(struct swim __iomem *base, int enable) { struct iwm __iomem *iwm_base =3D (struct iwm __iomem *)base; @@ -402,7 +403,7 @@ static int swim_seek(struct swim __iomem *base, int ste= p) if (step =3D=3D 0) return 0; =20 - for ( ; step > 0; step--) { + for (; step > 0; step--) { if (swim_step(base)) return -1; } @@ -413,7 +414,7 @@ static int swim_seek(struct swim __iomem *base, int ste= p) return 0; } =20 -static int swim_track(struct floppy_state *fs, int track) +static int swim_track(struct floppy_state *fs, int track) { struct swim __iomem *base =3D fs->swd->base; int ret; @@ -555,10 +556,10 @@ static blk_status_t swim_queue_rq(struct blk_mq_hw_ct= x *hctx, } =20 static struct floppy_struct floppy_type[4] =3D { - { 0, 0, 0, 0, 0, 0x00, 0x00, 0x00, 0x00, NULL }, /* no testing */ + { 0, 0, 0, 0, 0, 0x00, 0x00, 0x00, 0x00, NULL }, /* no testing */ { 720, 9, 1, 80, 0, 0x2A, 0x02, 0xDF, 0x50, NULL }, /* 360KB SS 3.5"*/ - { 1440, 9, 2, 80, 0, 0x2A, 0x02, 0xDF, 0x50, NULL }, /* 720KB 3.5" */ - { 2880, 18, 2, 80, 0, 0x1B, 0x00, 0xCF, 0x6C, NULL }, /* 1.44MB 3.5" */ + { 1440, 9, 2, 80, 0, 0x2A, 0x02, 0xDF, 0x50, NULL }, /* 720KB 3.5" */ + { 2880, 18, 2, 80, 0, 0x1B, 0x00, 0xCF, 0x6C, NULL }, /* 1.44MB 3.5" */ }; =20 static int get_floppy_geometry(struct floppy_state *fs, int type, @@ -585,10 +586,11 @@ static void setup_medium(struct floppy_state *fs) =20 if (swim_readbit(base, DISK_IN)) { struct floppy_struct *g; + fs->disk_in =3D 1; fs->write_protected =3D swim_readbit(base, WRITE_PROT); fs->type =3D swim_readbit(base, TWOMEG_MEDIA) ? - HD_MEDIA : DD_MEDIA; + HD_MEDIA : DD_MEDIA; fs->head_number =3D swim_readbit(base, SINGLE_SIDED) ? 1 : 2; get_floppy_geometry(fs, 0, &g); fs->total_secs =3D g->size; @@ -690,7 +692,7 @@ static int floppy_ioctl(struct block_device *bdev, blk_= mode_t mode, int err; =20 if ((cmd & 0x80) && !capable(CAP_SYS_ADMIN)) - return -EPERM; + return -EPERM; =20 switch (cmd) { case FDEJECT: @@ -809,7 +811,7 @@ static int swim_floppy_init(struct platform_device *pde= v) bool *data =3D pdev->dev.platform_data; bool fast_fclk =3D data && *data; struct queue_limits lim =3D { - .features =3D BLK_FEAT_ROTATIONAL, + .features =3D BLK_FEAT_ROTATIONAL, }; int err; int drive; @@ -961,7 +963,7 @@ static void swim_remove(struct platform_device *dev) static struct platform_driver swim_driver =3D { .probe =3D swim_probe, .remove =3D swim_remove, - .driver =3D { + .driver =3D { .name =3D CARDNAME, }, }; diff --git a/drivers/block/swim_asm.S b/drivers/block/swim_asm.S index 241088b12829..c373fb3fc750 100644 --- a/drivers/block/swim_asm.S +++ b/drivers/block/swim_asm.S @@ -5,7 +5,7 @@ * needs assembly language because is very timing dependent * this controller exists only on macintosh 680x0 based * - * Copyright (C) 2004,2008 Laurent Vivier + * Copyright (C) 2004, 2008 Laurent Vivier * * based on Alastair Bridgewater SWIM analysis, 2001 * based on netBSD IWM driver (c) 1997, 1998 Hauke Fath. @@ -110,7 +110,6 @@ sector_data_mark: /* read header */ =20 moveq #max_retry, %d2 - amark0: tstb %a2@ dbmi %d2, amark0 bpl signal_nonyb @@ -118,7 +117,6 @@ amark0: tstb %a2@ moveb %a5@, %a4@(o_track) =20 moveq #max_retry, %d2 - amark1: tstb %a2@ dbmi %d2, amark1 bpl signal_nonyb @@ -126,7 +124,6 @@ amark1: tstb %a2@ moveb %a5@, %a4@(o_side) =20 moveq #max_retry, %d2 - amark2: tstb %a2@ dbmi %d2, amark2 bpl signal_nonyb @@ -134,7 +131,6 @@ amark2: tstb %a2@ moveb %a5@, %a4@(o_sector) =20 moveq #max_retry, %d2 - amark3: tstb %a2@ dbmi %d2, amark3 bpl signal_nonyb @@ -142,7 +138,6 @@ amark3: tstb %a2@ moveb %a5@, %a4@(o_size) =20 moveq #max_retry, %d2 - crc0: tstb %a2@ dbmi %d2, crc0 bpl signal_nonyb @@ -150,7 +145,6 @@ crc0: tstb %a2@ moveb %a5@, %a4@(o_crc0) =20 moveq #max_retry, %d2 - crc1: tstb %a2@ dbmi %d2, crc1 bpl signal_nonyb @@ -197,13 +191,14 @@ mfm_read_data: =20 /* read data */ =20 - movel #sector_size-1, %d4 /* sector size */ + movel #sector_size - 1, %d4 /* sector size */ movew #max_retry, %d2 read_data_loop: moveb %a2@, %d5 andb #(.Lhr_fifo_1byte + .Lhr_fifo_2bytes), %d5 dbne %d2, read_data_loop beq data_exit + moveq #max_retry, %d2 moveb %a5@, %d3 bsr .Lmaybe_store @@ -219,7 +214,6 @@ read_data_loop: =20 movew #max_retry, %d2 data_crc0: - tstb %a2@ dbmi %d2, data_crc0 bpl data_exit @@ -227,9 +221,7 @@ data_crc0: moveb %a5@, %d5 =20 moveq #max_retry, %d2 - data_crc1: - tstb %a2@ dbmi %d2, data_crc1 bpl data_exit --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17DDC447817; Fri, 4 Sep 2026 09:36:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514594; cv=none; b=KZAU3lqYnJ/mF0RUxnP124x3dg8MEPRWLKi+//ksJ/lXHBk8rWNPq5WdNMe45wl9F/ZFAXf9dmWoHjENZ/Dgjin7hAVOzM6GQxCmwfiy6yBOrq+p2ZNMcZvXE2x7Jrw7xidxc/hlm7+Y5NY+GJfQ2A3SpsRw/4EX2A9iccn3YS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514594; c=relaxed/simple; bh=W/2peY7QXmgSVaUSqR3xSWS3rJJZzZGsQ2US1ly9C70=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=Gou0fL0PsZI9xvHzL+FnjNt4xk2KhNqXWdVOaB+IsLXSckhm3+EOQ8SNM90Gk6eoXiOl8vWoR9BrsBlr2sDrSW1uS+bUzpSvOG29imn0RqdyezFkB0YWjCfZ5W93UNfDvLmHB60MrIEYmdvVyK141ERnzsxkgUktPjDyjTCHG1Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=OtNPeOJ0; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="OtNPeOJ0" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfout.phl.internal (Postfix) with ESMTP id 50862EC0212; Fri, 4 Sep 2026 05:36:32 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Fri, 04 Sep 2026 05:36:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514592; x= 1788600992; bh=Z20/xYIt8naMl8dD/6e4TSmsRBPPZUUgtJg076bDEt0=; b=O tNPeOJ0Idr9G4JnBFhzF97dwGCxywtSgnhTCRa5P7XGY8U5QO/WI6z4sa5wCHj6p QaoITr3Mi/1gxE9cvaS0Vf7ldeFWH2CPkX5y9cjWDJK3Yr0DhuPPVoiJbt3aNFED unGZGXB4sD1c+hK3KRvUw+RTfyFx3GzEpkuD8/Y6jsT+sSRqP54KA2RpFM0qOjMJ Q0vrEeDwv+MAaAbnnXMkof1I7NnFk88+WbgoeM6BhhV6o+0AA+nVnPDYNEulg9g1 GAuYiZS5lsi6XXMHQsrOrfZCp11vu7b639IhYPNkKNVMc7zFD5PsiZj8G+s3qKwi MGJEdn8L+tq1Pplqy6zbg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFZ/TtYWX7QRSPqbWdhFvGKPdYLqSrS0kW5tw/ccCSeQwGXLU8z8+n4MTGG5Fz3xO fBhPKm+HgWFmiq+gJDvSVIfRvZvgV672b0RABACnDdhJF/iW3opz+U3/SP3bVUvVx8Q287 Ap1gWmRx+bP8FRnMF0HKeE0yfsMRD8AYBXtaUsZs5aI7BW+fV7e9Q0YJu0hP5K8l60oxGK XrcuXNo1hSmleRjGCb9wMFpOFKoRGwYOR+2UyWTZOvcSmWg9D5Za0czKtKfTDaJ7RbQZgm lIJH+OOpA0D60VJW1h483ZeutJ4e8G1K0sL6VJD12jwsAudayvIunnWKGaY8cBa7nccFWv heq/msEziktLWpOMZ9NXNM9QFw03T5eqezgpHov9MF9RWQ8uc4Edv/R7IuHCoFmgwVmc6D p7oXTf6J1Iql+X8lykrN8/QRdMhFHNDmE539dwFEenDiQq9kPEHccaXLM+oDr17kDN6mHs tY4FsfRtkugeqMnClXJdpN5RT+38uccuO/ShH9KSJIXKfp3o+zWYI4isIbG8Ak/FWRA+3/ VCX8BiV0NkybeCnb6xJ8PAKnB5JToOGsrKNo4ddnIAMCZ7PT1MP3ahu0/c7CRcDLApmwyg dL/0CqO4NAB2J5PsehnNM9ub1z/5pzFJ6/Xt3rISIBMLWtUiO83Hq8+tHjQQ X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:36:31 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <64ee742adc48218962a989017b9dc5622e2932c7.1788513997.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 31/33] swim: Define macros for constants Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Define a SEL_MASK macro to name the anonymous constant. Define STEPPING rather than re-use STEP because the latter is a command bit macro (see also GCR_MODE vs. SETGCR). No functional change, just better readability. Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/block/swim.c b/drivers/block/swim.c index a5be31b732b5..6f37a01219c2 100644 --- a/drivers/block/swim.c +++ b/drivers/block/swim.c @@ -105,6 +105,8 @@ struct iwm { =20 /* Select values for swim_select and swim_readbit */ =20 +#define SEL_MASK 0x100 + #define SEEK_POSITIVE 0x000 #define SEEK_NEGATIVE 0x004 #define STEP 0x001 @@ -115,6 +117,7 @@ struct iwm { #define SETMFM 0x101 #define SETGCR 0x105 =20 +#define STEPPING 0x001 #define READ_DATA_0 0x004 #define ONEMEG_DRIVE 0x005 #define SINGLE_SIDED 0x006 @@ -271,7 +274,7 @@ static inline void swim_select(struct swim __iomem *bas= e, int sel) { swim_write(base, phase, RELAX | PHASE_PIN_DIR); =20 - via1_set_head(sel & 0x100); + via1_set_head(sel & SEL_MASK); =20 swim_write(base, phase, (sel & CA_MASK) | PHASE_PIN_DIR); } @@ -366,7 +369,7 @@ static int swim_step(struct swim __iomem *base) { swim_action(base, STEP); udelay(150); - return swim_readbit_timeout(base, STEP, false, 20 * 1000); + return swim_readbit_timeout(base, STEPPING, false, 20 * 1000); } =20 static int swim_track00(struct swim __iomem *base) --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB9B844E64C; Fri, 4 Sep 2026 09:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514603; cv=none; b=VUmh3uGkk9o+dV/MDmGYZaQ99EXcAYsLnUeVGBlTzEYjfXEdp1CVmo3ktBuM0Wn53fy/J6pCTOla0dvcJ6F000S+v1ONI87edVAuAi0o9RNkQw66dzh++zOWvLLOwayznbzdL9mv7EGVOZ0piHNsoof8DeNP5wQT9IZFLjPj+Mk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514603; c=relaxed/simple; bh=mzkDrXBH4RomLX+jHLh/d6zM58mnDl0YDinRD4ebPt0=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=Xc4l4/GUWPopxJLxZgZrLuis2gPWz6a6UCzpWKIAUNjMjxKstB5Rz9s70h/6P9bLxhw/ZZ/JRD8LhgKbjpVIP/ghx/eKeyDGqybsrOfaTA9w0Yp51in0OhApFwLNIXdYKpYMIc+VlAfl8casQaTlx6B5l81YnmFqjY+6ThFNiHI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=TAcnlCFl; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="TAcnlCFl" Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.phl.internal (Postfix) with ESMTP id EDEED1400067; Fri, 4 Sep 2026 05:36:40 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Fri, 04 Sep 2026 05:36:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514600; x= 1788601000; bh=51+l+4t/eDclkKVdvo5tHtz9ZQ1eAbR09EDfIyzxuiQ=; b=T AcnlCFlPRk58OZiX1k6sNHjsfy94RydcwXlGMJOAUU00MP/hDI72wDqwzTfD4j1K wXGm+f6B7JGAYMI9DQsOc4kcVrEzqoSYERByPqfdtXTtO5KxtMeQ6m+5E4BHr5Dt l6IsIyR6re6d9YdWL7zhHJlkUD3dN6iUdLHGA1/eqfzAWYKgqrG4pB5D5hvkp3t/ FXvoluxr+0KVEwUkUIpLoejuvkSXYA55melQ/0uMLy1qk+EFJhLyzsqY9EsQKWlx FajEL7NWSygO4pHpZeWcUEwFL3uXsVULpoPA0PYaacVb8GgY9grKWSo7HWmm2Za6 tMEJduedY6eiErWj1jAYg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTES4bQ21oAzpNnp51xfFHSMQBPKtrMCV5iYYMBFJYMMGuku2wDZqHLDhf7MMkpQep sMe4CyNnIEY4dUJg6qGIApiDz7xq7NkSCScmKgrMc4345BLDBaaFf6c8TLqowSoQSjBNao tQAjHxJbuqzVv3VzZRZEacp4FA41Q9OcL5NDtbJMFMDUCcPGJR7zU6OainbhxZYK3NU11B Fa2x5PyGrJHtwPQxOc1oyHJXrbM2nyqpGGOSM3yceNTB7ODw+A07JKEQZT40T9t1sfxdOY Z+GEWRwgrC3pQuxmclLHPwxPnQJ8sX9Nh9G6tEyIm0Ldv+rMccWy5ZFRy0U8vBhf8uuzsH AVt6esPCMxKRONG3sfwnrkafd7I09OT5/lkgiGpE6UIVBwy4uskQObAJS0Dn4X7ghYHzaD KNHMbZeSVOZYXy20uQHrP2P4k7xgLJNl9xvR1k5641Me3/bkXkFGwe4bcna5Qvmp2QMe9P FQBZmj9ivzHkS/vRMftiMZLb+/Br7uDQ7eyh0T8Curi1/jvtmnTw51oFtBkxMaUUODomuF l5sBe7lWn/mCG3mMgBov1xbK3veV1wHVeR7npulmD6uEmVnm+S/35Mkilr1578PQSsvcAB KRAK8iVcsAPXpOlpEFKd2GXWKd2FABDiW8/EWlwrs1LH0n05OvKr/fUidSXw X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:36:38 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <7eee06428905fd7ad60909d9b5726c15cde1b844.1788513997.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 32/33] swim: Define symbols for constants Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Define local symbols to give some meaning to anonymous constants. No functional change. Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim_asm.S | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/block/swim_asm.S b/drivers/block/swim_asm.S index c373fb3fc750..a1879cfaa6f4 100644 --- a/drivers/block/swim_asm.S +++ b/drivers/block/swim_asm.S @@ -43,6 +43,10 @@ .equ sector_size, 512 .equ .Lmark_sequence_len, 4 =20 + .equ .Lmr_clear_fifo, 0x01 + .equ .Lmr_action, 0x08 + .equ .Lmr_write_action, 0x18 + .equ .Lhr_crc_error, 0x02 .equ .Lhr_fifo_2bytes, 0x40 .equ .Lhr_fifo_1byte, 0x80 @@ -95,11 +99,11 @@ sector_data_mark: lea %a3@(read_data), %a5 lea %a3@(read_mark), %a3 =20 - moveb #0x18, %a3@(write_mode0 - read_mark) - moveb #0x01, %a3@(write_mode1 - read_mark) - moveb #0x01, %a3@(write_mode0 - read_mark) + moveb #.Lmr_write_action, %a3@(write_mode0 - read_mark) + moveb #.Lmr_clear_fifo, %a3@(write_mode1 - read_mark) + moveb #.Lmr_clear_fifo, %a3@(write_mode0 - read_mark) tstb %a3@(read_error - read_mark) - moveb #0x08, %a3@(write_mode1 - read_mark) + moveb #.Lmr_action, %a3@(write_mode1 - read_mark) =20 lea sector_address_mark, %a1 moveq #.Lmark_sequence_len, %d4 @@ -157,7 +161,7 @@ crc1: tstb %a2@ =20 moveq #0, %d0 signal_nonyb: - moveb #0x18, %a3@(write_mode0 - read_mark) + moveb #.Lmr_write_action, %a3@(write_mode0 - read_mark) rts =20 .global swim_read_sector_data @@ -177,11 +181,11 @@ mfm_read_data: lea %a3@(read_data), %a5 lea %a3@(read_mark), %a3 =20 - moveb #0x18, %a3@(write_mode0 - read_mark) - moveb #0x01, %a3@(write_mode1 - read_mark) - moveb #0x01, %a3@(write_mode0 - read_mark) + moveb #.Lmr_write_action, %a3@(write_mode0 - read_mark) + moveb #.Lmr_clear_fifo, %a3@(write_mode1 - read_mark) + moveb #.Lmr_clear_fifo, %a3@(write_mode0 - read_mark) tstb %a3@(read_error - read_mark) - moveb #0x08, %a3@(write_mode1 - read_mark) + moveb #.Lmr_action, %a3@(write_mode1 - read_mark) =20 lea sector_data_mark, %a1 moveq #.Lmark_sequence_len, %d4 @@ -239,7 +243,7 @@ data_crc1: subl %d4, %d0 =20 data_exit: - moveb #0x18, %a3@(write_mode0 - read_mark) + moveb #.Lmr_write_action, %a3@(write_mode0 - read_mark) rts =20 .Lmaybe_store: --=20 2.52.0 From nobody Sat Sep 26 05:27:39 2026 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43E2F450409; Fri, 4 Sep 2026 09:36:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514614; cv=none; b=cArEu8y3BKt4SG+2ulQV5PVeQexVJXkybJ8ZO6lCnqVvx88MhRW6uNch1h3htBM588aYYxXuPec2Vvjo0V5wJF6dyaJgvCD/VYQaCAQaTgKd2xt670X8q3lIPkjelahkGnQ6T8RSluLmBMUiRmdRF0sZkL6jh8nC0n8lpqFeWvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788514614; c=relaxed/simple; bh=D7wrCCZ9JI5Cjc6MxSR7qNaRHAJnB4XNcHilwtnBemA=; h=To:Cc:Message-ID:In-Reply-To:References:From:Subject:Date; b=HLB3PMj7EcCKjB0sd+LaelRMfliCynrmnEmO8Iyw6w7eRXDI+kevuJ0UWBDvIMyomytM+kD1oN1lamFuFHOZAsVjgySd7hHoGKwinmSpgtp8FI3nW8AaVUgZOBhVg8CZNKkzILdtCjOumboYzW59U/qaodqMLBFaZeDatuIN9bY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org; spf=none smtp.mailfrom=linux-m68k.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=tiGoHCCB; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux-m68k.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="tiGoHCCB" Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id 7D609140008F; Fri, 4 Sep 2026 05:36:51 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Fri, 04 Sep 2026 05:36:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1788514611; x= 1788601011; bh=iXrazyCh/11Z12ZzetWRHxSxQdJ0JtLx7eEGdovmzZg=; b=t iGoHCCB6tSRU+np/TK/r9nnHXJxvGnpZtQjL71T3Fw934Z+5OiFjRg9qOi7FFQuG 0lMqijlW1XqUhXvd5v2ln/yzT0o7Ri8Rb+Ue1h39JcqYpX6Vtcx9MVKFCdie4qaJ b++zovDuIrxGE4/lSXV0DYS63iy36u3kFKQXhSzrY8el7ThEKrVuqIpB2I5K/Ttn wlqKomxxosdPDGrhXvsVmPHML9zcSfw8odoFO2pbAQDKFsova/FyT/BK0azIP9i6 NiGnWO7zlpacGxZTRJnKKitotslb7rvUTjL+cXwGSiHufTJaukoNmlNsBEzrDOqX I77SUKLbaqbLLnAfSGkbg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTES4bQ21oAzpNnp51xfFHSMQBPKtrMCV5iYYMBFJYMMGuku2wDZqHLDhf7MMkpQep sMe4CyNnIEY4dUJg6qGIApiDz7xq7NkSCScmKgrMc4345BLDBaaFf6c8TLqowSoQSjBNao tQAjHxJbuqzVv3VzZRZEacp4FA41Q9OcL5NDtbJMFMDUCcPGJR7zU6OainbhxZYK3NU11B Fa2x5PyGrJHtwPQxOc1oyHJXrbM2nyqpGGOSM3yceNTB7ODw+A07JKEQZT40T9t1sfxdOY Z+GEWRwgrC3pQuxmclLHPwxPnQJ8sX9Nh9G6tEyIm0Ldv+rMccWy5ZFRy0U8vBhf8uuzNN F2WMe0qRthExh6TdZPXb3m3FXkPtbpCwwYVznaBjm+aHyhdUHHA+ea1LtPr2OIDxKEp5kI +aqLRWwKTd3fklpa4rRueC2sMUZFZLLANbgQWQJI0EUnzxpRNawV59emu24A3EzZyCbV2Q CI36VPDhleCyTt9ibFBm3KJCRW9VSGuMQgwOC4EtWYtmX+moho1B3xbJDDsB8NtH07TIE2 3FQhpuG9C3Z3i+jT8MDQJI+xvleWX1akNm8f756bxpGrvCfzfolq36bbCwkqnkW+fRiCao 3QnFqxGA1IAwJwBD06JQPS7T2maDgF23F0MN3JLWWcP62vUbxYmALTit0R9Q X-ME-Proxy: Feedback-ID: i58a146ae:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Sep 2026 05:36:49 -0400 (EDT) To: Jens Axboe , Laurent Vivier Cc: Geert Uytterhoeven , Joshua Thompson , linux-block@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Message-ID: <0810de0df2a670d4d9ccad4e747be2c4b46f6d6e.1788513997.git.fthain@linux-m68k.org> In-Reply-To: References: From: Finn Thain Subject: [PATCH v3 33/33] swim: Unexport global symbols Date: Fri, 04 Sep 2026 19:26:36 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These symbols aren't used outside of this file so use local ones. No functional change. Reviewed-by: Laurent Vivier Signed-off-by: Finn Thain Tested-by: Stan Johnson --- drivers/block/swim_asm.S | 218 ++++++++++++++++++++------------------- 1 file changed, 112 insertions(+), 106 deletions(-) diff --git a/drivers/block/swim_asm.S b/drivers/block/swim_asm.S index a1879cfaa6f4..489512a0f561 100644 --- a/drivers/block/swim_asm.S +++ b/drivers/block/swim_asm.S @@ -14,33 +14,33 @@ * 2008-11-05 (lv) - add get_swim_mode */ =20 - .equ write_data, 0x0000 - .equ write_mark, 0x0200 - .equ write_CRC, 0x0400 - .equ write_parameter,0x0600 - .equ write_phase, 0x0800 - .equ write_setup, 0x0a00 - .equ write_mode0, 0x0c00 - .equ write_mode1, 0x0e00 - .equ read_data, 0x1000 - .equ read_mark, 0x1200 - .equ read_error, 0x1400 - .equ read_parameter, 0x1600 - .equ read_phase, 0x1800 - .equ read_setup, 0x1a00 - .equ read_status, 0x1c00 - .equ read_handshake, 0x1e00 - - .equ o_side, 0 - .equ o_track, 1 - .equ o_sector, 2 - .equ o_size, 3 - .equ o_crc0, 4 - .equ o_crc1, 5 - - .equ seek_time, 30000 - .equ max_retry, 40 - .equ sector_size, 512 + .equ .Lwrite_data, 0x0000 + .equ .Lwrite_mark, 0x0200 + .equ .Lwrite_CRC, 0x0400 + .equ .Lwrite_parameter, 0x0600 + .equ .Lwrite_phase, 0x0800 + .equ .Lwrite_setup, 0x0a00 + .equ .Lwrite_mode0, 0x0c00 + .equ .Lwrite_mode1, 0x0e00 + .equ .Lread_data, 0x1000 + .equ .Lread_mark, 0x1200 + .equ .Lread_error, 0x1400 + .equ .Lread_parameter, 0x1600 + .equ .Lread_phase, 0x1800 + .equ .Lread_setup, 0x1a00 + .equ .Lread_status, 0x1c00 + .equ .Lread_handshake, 0x1e00 + + .equ .Lo_side, 0 + .equ .Lo_track, 1 + .equ .Lo_sector, 2 + .equ .Lo_size, 3 + .equ .Lo_crc0, 4 + .equ .Lo_crc1, 5 + + .equ .Lseek_time, 30000 + .equ .Lmax_retry, 40 + .equ .Lsector_size, 512 .equ .Lmark_sequence_len, 4 =20 .equ .Lmr_clear_fifo, 0x01 @@ -63,7 +63,7 @@ =20 moveq #-1, %d1 subq #1, %d4 - movew #seek_time, %d2 + movew #.Lseek_time, %d2 =20 5: tstb %a2@ dbmi %d2, 5b @@ -88,80 +88,86 @@ swim_read_sector_header: unlk %a6 rts =20 -sector_address_mark: +.Lsector_address_mark: .byte 0xa1, 0xa1, 0xa1, 0xfe -sector_data_mark: +.Lsector_data_mark: .byte 0xa1, 0xa1, 0xa1, 0xfb =20 .Lmfm_read_header: movel %a6@(0x08), %a3 - lea %a3@(read_handshake), %a2 - lea %a3@(read_data), %a5 - lea %a3@(read_mark), %a3 + lea %a3@(.Lread_handshake), %a2 + lea %a3@(.Lread_data), %a5 + lea %a3@(.Lread_mark), %a3 =20 - moveb #.Lmr_write_action, %a3@(write_mode0 - read_mark) - moveb #.Lmr_clear_fifo, %a3@(write_mode1 - read_mark) - moveb #.Lmr_clear_fifo, %a3@(write_mode0 - read_mark) - tstb %a3@(read_error - read_mark) - moveb #.Lmr_action, %a3@(write_mode1 - read_mark) + moveb #.Lmr_write_action, %a3@(.Lwrite_mode0 - .Lread_mark) + moveb #.Lmr_clear_fifo, %a3@(.Lwrite_mode1 - .Lread_mark) + moveb #.Lmr_clear_fifo, %a3@(.Lwrite_mode0 - .Lread_mark) + tstb %a3@(.Lread_error - .Lread_mark) + moveb #.Lmr_action, %a3@(.Lwrite_mode1 - .Lread_mark) =20 - lea sector_address_mark, %a1 + lea .Lsector_address_mark, %a1 moveq #.Lmark_sequence_len, %d4 bsr .Lmfm_mark_check tstl %d1 - bne signal_nonyb + bne .Lsignal_nonyb =20 /* read header */ =20 - moveq #max_retry, %d2 -amark0: tstb %a2@ - dbmi %d2, amark0 - bpl signal_nonyb + moveq #.Lmax_retry, %d2 +.Lamark0: + tstb %a2@ + dbmi %d2, .Lamark0 + bpl .Lsignal_nonyb =20 - moveb %a5@, %a4@(o_track) + moveb %a5@, %a4@(.Lo_track) =20 - moveq #max_retry, %d2 -amark1: tstb %a2@ - dbmi %d2, amark1 - bpl signal_nonyb + moveq #.Lmax_retry, %d2 +.Lamark1: + tstb %a2@ + dbmi %d2, .Lamark1 + bpl .Lsignal_nonyb =20 - moveb %a5@, %a4@(o_side) + moveb %a5@, %a4@(.Lo_side) =20 - moveq #max_retry, %d2 -amark2: tstb %a2@ - dbmi %d2, amark2 - bpl signal_nonyb + moveq #.Lmax_retry, %d2 +.Lamark2: + tstb %a2@ + dbmi %d2, .Lamark2 + bpl .Lsignal_nonyb =20 - moveb %a5@, %a4@(o_sector) + moveb %a5@, %a4@(.Lo_sector) =20 - moveq #max_retry, %d2 -amark3: tstb %a2@ - dbmi %d2, amark3 - bpl signal_nonyb + moveq #.Lmax_retry, %d2 +.Lamark3: + tstb %a2@ + dbmi %d2, .Lamark3 + bpl .Lsignal_nonyb =20 - moveb %a5@, %a4@(o_size) + moveb %a5@, %a4@(.Lo_size) =20 - moveq #max_retry, %d2 -crc0: tstb %a2@ - dbmi %d2, crc0 - bpl signal_nonyb + moveq #.Lmax_retry, %d2 +.Lcrc0: + tstb %a2@ + dbmi %d2, .Lcrc0 + bpl .Lsignal_nonyb =20 - moveb %a5@, %a4@(o_crc0) + moveb %a5@, %a4@(.Lo_crc0) =20 - moveq #max_retry, %d2 -crc1: tstb %a2@ - dbmi %d2, crc1 - bpl signal_nonyb + moveq #.Lmax_retry, %d2 +.Lcrc1: + tstb %a2@ + dbmi %d2, .Lcrc1 + bpl .Lsignal_nonyb =20 - moveb %a5@, %a4@(o_crc1) + moveb %a5@, %a4@(.Lo_crc1) =20 moveb %a2@, %d5 andb #.Lhr_crc_error, %d5 - bne signal_nonyb + bne .Lsignal_nonyb =20 moveq #0, %d0 -signal_nonyb: - moveb #.Lmr_write_action, %a3@(write_mode0 - read_mark) +.Lsignal_nonyb: + moveb #.Lmr_write_action, %a3@(.Lwrite_mode0 - .Lread_mark) rts =20 .global swim_read_sector_data @@ -170,80 +176,80 @@ swim_read_sector_data: moveml %d1-%d5/%a0-%a5,%sp@- movel %a6@(0x0c), %a4 moveq #-1, %d0 - bsr mfm_read_data + bsr .Lmfm_read_data moveml %sp@+, %d1-%d5/%a0-%a5 unlk %a6 rts =20 -mfm_read_data: +.Lmfm_read_data: movel %a6@(0x08), %a3 - lea %a3@(read_handshake), %a2 - lea %a3@(read_data), %a5 - lea %a3@(read_mark), %a3 + lea %a3@(.Lread_handshake), %a2 + lea %a3@(.Lread_data), %a5 + lea %a3@(.Lread_mark), %a3 =20 - moveb #.Lmr_write_action, %a3@(write_mode0 - read_mark) - moveb #.Lmr_clear_fifo, %a3@(write_mode1 - read_mark) - moveb #.Lmr_clear_fifo, %a3@(write_mode0 - read_mark) - tstb %a3@(read_error - read_mark) - moveb #.Lmr_action, %a3@(write_mode1 - read_mark) + moveb #.Lmr_write_action, %a3@(.Lwrite_mode0 - .Lread_mark) + moveb #.Lmr_clear_fifo, %a3@(.Lwrite_mode1 - .Lread_mark) + moveb #.Lmr_clear_fifo, %a3@(.Lwrite_mode0 - .Lread_mark) + tstb %a3@(.Lread_error - .Lread_mark) + moveb #.Lmr_action, %a3@(.Lwrite_mode1 - .Lread_mark) =20 - lea sector_data_mark, %a1 + lea .Lsector_data_mark, %a1 moveq #.Lmark_sequence_len, %d4 bsr .Lmfm_mark_check tstl %d1 - bne data_exit + bne .Ldata_exit =20 /* read data */ =20 - movel #sector_size - 1, %d4 /* sector size */ - movew #max_retry, %d2 -read_data_loop: + movel #.Lsector_size - 1, %d4 /* sector size */ + movew #.Lmax_retry, %d2 +.Lread_data_loop: moveb %a2@, %d5 andb #(.Lhr_fifo_1byte + .Lhr_fifo_2bytes), %d5 - dbne %d2, read_data_loop - beq data_exit + dbne %d2, .Lread_data_loop + beq .Ldata_exit =20 - moveq #max_retry, %d2 + moveq #.Lmax_retry, %d2 moveb %a5@, %d3 bsr .Lmaybe_store dbra %d4, 1f - bra data_crc0 + bra .Ldata_crc0 1: andb #.Lhr_fifo_2bytes, %d5 - beq read_data_loop + beq .Lread_data_loop moveb %a5@, %d3 bsr .Lmaybe_store - dbra %d4, read_data_loop + dbra %d4, .Lread_data_loop =20 /* read CRC */ =20 - movew #max_retry, %d2 -data_crc0: + movew #.Lmax_retry, %d2 +.Ldata_crc0: tstb %a2@ - dbmi %d2, data_crc0 - bpl data_exit + dbmi %d2, .Ldata_crc0 + bpl .Ldata_exit =20 moveb %a5@, %d5 =20 - moveq #max_retry, %d2 -data_crc1: + moveq #.Lmax_retry, %d2 +.Ldata_crc1: tstb %a2@ - dbmi %d2, data_crc1 - bpl data_exit + dbmi %d2, .Ldata_crc1 + bpl .Ldata_exit =20 moveb %a5@, %d5 =20 moveb %a2@, %d5 andb #.Lhr_crc_error, %d5 - bne data_exit + bne .Ldata_exit =20 /* return number of bytes read */ =20 - movel #sector_size, %d0 + movel #.Lsector_size, %d0 addw #1, %d4 subl %d4, %d0 =20 -data_exit: - moveb #.Lmr_write_action, %a3@(write_mode0 - read_mark) +.Ldata_exit: + moveb #.Lmr_write_action, %a3@(.Lwrite_mode0 - .Lread_mark) rts =20 .Lmaybe_store: --=20 2.52.0