From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6EF73A3E64 for ; Mon, 4 May 2026 10:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777890486; cv=none; b=I7WBl2alb11KD6PTm5Un59XQv4EuQsIo0OMM1Mkgk/x0Qbz9GmwumzpAuCgC0oduDdbYbbXgq6AyMjbBGmsUXn5lq6pJVoyJNrKN10wUstWnkcXfRouwdvHD0U0JMtJ6kTh+ZAzd/2xbXMsxdp6KUugl4qDGiJQUrBipG4l21pE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777890486; c=relaxed/simple; bh=5xdOX+5arWSGEvcko0QhRQZxIy5sg/8ZA7krb4Kpmuo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=r45JLd6zMHF9jQnVJSpQLB8yV1C1AKjM+cQZBaYUaOJSN7JvYuNTcDrsYRrIPuPxjLUwsAImdO3/181vhxGd3drfOQijTTUokagBdSrPVvUmP3B44hNiH+bpqbZVcLm89qb6gazD6/USGhWipsD1xZX9iPGhpR5eyr5jvB49YTg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-83537a80ab6so798396b3a.1 for ; Mon, 04 May 2026 03:28:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777890485; x=1778495285; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:reply-to:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=36PFWv+dxWmp+SudS0+HKGu6RNXmbG2x8E/T6lDWSiQ=; b=esMSRHM1msvZeOly5wAX8kO0+goeRgKARLrKk6XzWdBDQ3h4e7jcFUJO9ce2x7fMHZ QX4AYjnuRhTtUP/+WRk/ogY0QrxWr292UdwDOnUe/VH4Vy3vBvBOmpnnL+8yS5wS4QfH cJW0+tWfPJuj6VLOfEnDbUJRrlIeDV5M9ygVoaJgBnxG9tXJTLc5yMhv/rc69Tx5KrST /zPDEXUXZDnEQSpcA6auhIJNSN2IoEf3cOf5plwgjW1CijRasgNeCYNc3aB0WkWAwNIE XXprqu7QVeI33DJp9HKykxRqUW/BFQfzJYM8fTZb6ppHlklLLnH4gurKoQRTdC8admme cQXA== X-Forwarded-Encrypted: i=1; AFNElJ+HNKebMQi8/1tTxc9n9ePWD3NnWJUEZcEuNKTuSWbJV1c6lJbQ/uaauOILcSz3EfWlkwhyKTRyeQKP6rY=@vger.kernel.org X-Gm-Message-State: AOJu0YzoM2UvD7sndeeftSYpyr6WdtSQa45R3ZkslqL2jDa92xFgeN+G /Qca0/g9IHVegCAb3EvcfjxB4Cwz14Nsfw7Q0e6H2VX/nblKfEmfPCAM X-Gm-Gg: AeBDieubpjlnyRrlUV4V2n2eOYNwBv5xjhC6dMhrIQSKUobzOCMkGJ4vj0GQ6/Zdny+ fdNQS3t5YIGiaKocd1XYOYFbaqJ95SJWgOc/63A9E4bonDxRVaeGt8bmUCiGToAozvSgSdaKdKU 7lpfcP5rsag4iKPjXImpAq+nYA7kwIqDYAbmH6CldHBiJv0mqQpbnwUKeDhSxUXMVI3azsikQJ/ TO21NNzurAKq1JirHKApnSD6L7mQKHHUw1M9dkHBejnb9YuS1NSBodZh32tg9psAkiFBaaYITkb BYAR3qV/3Vg23JtGYGk2TFhirJLdp4G43vlxVw329AdYFDSbjzQY5FQQEIHPRck69+DicJrG3m7 3z7kXC31PxtIO/vGIHIrTHBvKs4kgvUXVzqXBTrq7NwTp+m3IRBBEBGLWLErFKDXZcuw4EveVkE oV5Lk5vtCW+Iw2WfuA9cHQ85YDi0Z9e7VYJrCAJHe3dngQxK6M0jIUYIuRHLyIpiNFAsAX X-Received: by 2002:a05:6a00:aa8c:b0:82f:623f:e5b3 with SMTP id d2e1a72fcca58-8352d2b58d9mr9304507b3a.34.1777890484980; Mon, 04 May 2026 03:28:04 -0700 (PDT) Received: from [10.68.32.41] (bba-86-97-226-202.alshamil.net.ae. [86.97.226.202]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-835158a26d3sm11222616b3a.19.2026.05.04.03.28.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 May 2026 03:28:04 -0700 (PDT) Message-ID: <05c7b472-6335-49f8-8c2c-73737b300f1f@linux.com> Date: Mon, 4 May 2026 14:27:52 +0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Reply-To: efremov@linux.com Subject: Re: [PATCH] floppy: select FDC before arming timeout work To: Cen Zhang , axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, baijiaju1990@gmail.com References: <20260504032853.316099-1-zzzccc427@gmail.com> Content-Language: en-US, ru-RU From: "Denis Efremov (Oracle)" In-Reply-To: <20260504032853.316099-1-zzzccc427@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, thank you for the patch. On 04/05/2026 07:28, Cen Zhang wrote: > floppy_shutdown() uses current_fdc to choose which controller state > to mark for reset when fd_timeout expires. lock_fdc() currently arms > that timeout before set_fdc() has selected the drive/FDC and updated > current_drive/current_fdc. > > drive_params[drive].timeout is user configurable, so the timeout > can be immediate. Even with a non-zero timeout, a delayed caller can > leave the timeout work running while set_fdc() is still testing > fdc_state[fdc].rawcmd and updating the adjacent reset bitfield. The > timeout can then use stale selected-controller state or race the reset > bitfield update. > > Move the timeout arm after set_fdc() in lock_fdc(), and keep the > same ordering for the direct floppy_queue_rq() path. This ensures > fd_timeout cannot run until the selected-controller state describes > the operation being timed. > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Signed-off-by: Cen Zhang Reviewed-by: Denis Efremov (Oracle) > --- > drivers/block/floppy.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c > index 92e446a64371..f9b924a2f276 100644 > --- a/drivers/block/floppy.c > +++ b/drivers/block/floppy.c > @@ -894,8 +894,8 @@ static int lock_fdc(int drive) > > command_status = FD_COMMAND_NONE; > > - reschedule_timeout(drive, "lock fdc"); > set_fdc(drive); > + reschedule_timeout(drive, "lock fdc"); > return 0; > } > > @@ -2874,8 +2874,8 @@ static blk_status_t floppy_queue_rq(struct blk_mq_hw_ctx *hctx, > spin_unlock_irq(&floppy_lock); > > command_status = FD_COMMAND_NONE; > - __reschedule_timeout(MAXTIMEOUT, "fd_request"); > set_fdc(0); > + __reschedule_timeout(MAXTIMEOUT, "fd_request"); > process_fd_request(); > is_alive(__func__, ""); > return BLK_STS_OK; Thanks, Denis