Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp399401ybf; Sat, 29 Feb 2020 06:14:35 -0800 (PST) X-Google-Smtp-Source: APXvYqwPTzdmXF4b28nRC1itSt2mRq4AW9F28tHhgHbHw45M4JuRO1qX9Zw0ciO25cxGixRZLJlQ X-Received: by 2002:a05:6830:c9:: with SMTP id x9mr7015668oto.345.1582985675149; Sat, 29 Feb 2020 06:14:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582985675; cv=none; d=google.com; s=arc-20160816; b=TxvfuQE0co6+y3/RaTRgUYj3WBmeAUjpmOAvYU2K+yjGyKhbyfdtdZNb0Z4UJVhj4m QS9TujGh9ExchrWTuxOBuWR5aP0IrabNLgAlWst5ihqEtigWgpZ2BpLitlfU64yoMULi EO9kVDmi2QZMPi7O5qj/gCCkQ088wLe9sZQef8A0j8jMnkvrQR9ho4OYVeutGE3L0VMm yHLks/h96yAEvKokllhO1m/EoyJXN2awmfVJDxnxbdYD/GWnF67llKUtbo9qrqSv5+lE aH/bGoKdULxywyPiA29e+uFDaCNTCTuiLizM65LSOpkwmqZdjhR+mLbcfhJMXBYHhaEv a0aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=GQrj3VLKMAzi2LR30qtPkWH3XCofYTyXbPtHRUM111M=; b=xp/XmOppxmtZcCulrXziLhSgpfPPMHaJAxBAv9Jzo1jNzTeCLcUDApxYyqxohrPI9P aea+Md+4xDsFZirsthWn2Q8oKvPTugvTby5fm/ATsDX0LfYfyJ4/mBXmzkS655dXfBwQ o/xhqI6RS0a1QQW+erq4Vw89SCum8TvKs2WCOswbhDVeLSmN1gEZW8uTTJR9b7cTCXD7 7egWhJomG5+mkn+xBMdR+tll6Vvb3/QlKXLEzTI4XYR7diSBsSbINik/fWSfJVagdTXU 7pLlMXaoQ+tEeUvQITAWAWaOYQ6JF21WlYfmLuDb1R4Hcfs9/6QrfJkPQu5Cx8tOEeQr yX7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e19si3139218otl.145.2020.02.29.06.14.22; Sat, 29 Feb 2020 06:14:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727069AbgB2OOE (ORCPT + 99 others); Sat, 29 Feb 2020 09:14:04 -0500 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:31908 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727049AbgB2OOE (ORCPT ); Sat, 29 Feb 2020 09:14:04 -0500 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 01TEDsh9023477; Sat, 29 Feb 2020 15:13:54 +0100 Date: Sat, 29 Feb 2020 15:13:54 +0100 From: Willy Tarreau To: Linus Torvalds Cc: Denis Efremov , Jens Axboe , Linux Kernel Mailing List , linux-block Subject: Re: [PATCH 00/10] floppy driver cleanups (deobfuscation) Message-ID: <20200229141354.GA23095@1wt.eu> References: <20200224212352.8640-1-w@1wt.eu> <0f5effb1-b228-dd00-05bc-de5801ce4626@linux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Linus, On Wed, Feb 26, 2020 at 09:49:05AM -0800, Linus Torvalds wrote: > On Wed, Feb 26, 2020 at 6:57 AM Denis Efremov wrote: > > > > If Linus has no objections (regarding his review) I would prefer to > > accept 1-10 patches rather to resend them again. They seems complete > > to me as the first step. > > I have no objections, and the patches 11-16 seem to have addressed all > my "I wish.." concerns too (except for the "we should rewrite or > sunset the driver entirely"). Looks fine to me. So I continued to work on this cleanup and regardless of the side I attacked this hill, it progressively stalled once I got closer to the interrupt and delayed work stuff. I understood the root cause of the problem, it's actually double: - single interrupt for multiple FDCs : this means we need to have some global context to know what we're working with. It is not completely true because we could very well have a list of pending operations per FDC to scan on interrupt and update them when the interrupt strikes and the FDC reports a completion. I noticed that raw_cmd, raw_buffer, inr, current_req, _floppy, plus a number of function pointers used to handle delayed work should in fact be per-FDC if we didn't want to change them at run time ; - single DMA channel for multiple FDCs : regardless of what could be done for the interrupt above, we're still stuck with a single DMA setup at once, which requires to issue reset_fdc() here and there, making it clear we can't work with multiple FDCs in parallel. Given the number of places where such global variables are set, I'm not totally confident in the fact that nowhere we keep a setting that was assigned for the FDC in the previous request. For example a spurious (or late) interrupt could slightly affect the fdc_state[] and maybe even emit FD_SENSEI to the current controller. Also this comment in floppy_interrupt() made me realize the driver pre-dates SMP support: /* It is OK to emit floppy commands because we are in an interrupt * handler here, and thus we have to fear no interference of other * activity. */ It seems that changing the current FDC is still only protected by the fdc_busy bit, but that the interrupt handler doesn't check if anything is expected before touching bits related to current_fdc. All this made me wonder if we really want to continue to maintain the support for multiple FDCs. I checked all archs, and only x86, alpha and powerpc support more than one FDC, 2 to be precise (hence up to 8 drives). I have the impression that if we keep a single FDC we'll have a cleaner code that doesn't need to change global settings under us when doing resets or scans. So I don't know if that's something interesting to pursue. I also noticed that a lot of global variables are inter-dependent and should probably be moved to fdc_state[] so that what's per-FDC is now more explicit, except that this struct is exposed to userland via the FDGETFDCSTAT ioctl (but that could be changed so that the fdc_state is just a struct inside a per-fdc larger struct). At least now I get a better picture of the little ROI felt trying to clean this, and I don't think that even a complete rewrite as you suggested would address all the issues at all. So if you or Denis think there's some value in me continuing to explore one of these areas, I can continue, otherwise I can simply resend the last part of my series with the few missing Cc and be done with it. Willy