Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp371409ybb; Fri, 10 Apr 2020 01:38:04 -0700 (PDT) X-Google-Smtp-Source: APiQypJMiMX0Z8D+3GMmmigvRql2PCrS6th6IJV5k+F5DQTMD3bT6MdmB+0wn/FvsZvoYL10u7WF X-Received: by 2002:a05:620a:1f3:: with SMTP id x19mr2919408qkn.306.1586507883993; Fri, 10 Apr 2020 01:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586507883; cv=none; d=google.com; s=arc-20160816; b=xBGnM0O4bzDrz2qQ/D9l8bUdfZc1qCy3OFuLkVzBtbhRPYiAf1MuY0D8nsIsde9VfD N7buGtgqZ3NM2A0HJOGTWZuKziTUAb7GfIwzvlTaT8J1CT82vWJu0xk5Vo1bNvW7JxUS QZlfWk9gmpxQiJiHW36efrc+FgYJObcJ4ANd+JFv+aPH+S+zovUvHTmoPMxLRS9F+Xbr LPubLsG9BqKnq7Owsnf6Vb1yD5g6bBquHNApjlnkB4Y2gNviledTwyLlIOZGedYvXfu4 PLMhTbRe5i6yDKNBCuX2kAHZrEkzPfEsMInz241TW7hFnEy9AouTU2xGdE43W3yeNyht 3rdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:subject:autocrypt:from:references:cc:to; bh=DcH37kFw3pA3TszaAlB4FxdsO6scQAKynKBKosGJvw8=; b=ZFPBWjD64O9xciuhIKX92TpFamdKOlGAZSoBPQXCDD2vTxl8kReu64jbmJeRppEJ1H /4WJfkGb1MUrUeSO+KcVfiw2I2BYRv4ZZ7g6smh/2zxajOv2zEWIQz5QjTv0AdTEtNDk eZLrugMZXsB9MSdspkS+K6B3wxzSEiauK6JUR+78y9WG7py84ebnsoDp0Z9AIxf1TCME uWT5gnQmFsgm1hX700u22G7zGUUbpeXheOm63el+guBwQ6x+ttoaYoC8sEPEusEiZvjU PO4JgGLZdRqgOOCVSnQYnDcmxJjIoIX3E8umCxCWRv4JeX1PupdR996xu33EzKZS4qo4 1sYA== 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 z36si743038qta.352.2020.04.10.01.37.48; Fri, 10 Apr 2020 01:38:03 -0700 (PDT) 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 S1725955AbgDJIf4 (ORCPT + 99 others); Fri, 10 Apr 2020 04:35:56 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:43994 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725893AbgDJIfz (ORCPT ); Fri, 10 Apr 2020 04:35:55 -0400 Received: by mail-lf1-f65.google.com with SMTP id k28so833678lfe.10; Fri, 10 Apr 2020 01:35:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:autocrypt:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=DcH37kFw3pA3TszaAlB4FxdsO6scQAKynKBKosGJvw8=; b=NNfvw6+PavF+mc8vRL6F585DhlDMhbFQul6ultsRxTpdBQh0Q5icTrp6cGPm0iRAj0 6I9xcKKta4iK2ZNdBXaI3FLcGplWpfhFsmYAAKFu/8v1CW//xWxIEnxXQEUZxkmQycsS CBddePTUiwTD1Naw7h3lWAhoWTLMWy9xaWAgYVSfnMKv01UMEq4hWXcsLeNIKGVTtqjP qd+xL47UEwbo5gf0kQb4GCVNRNtdtVppSruWM0D20tRMSWmzUYWO52iwf0JMAK3R5MyZ 4kzlfwXGXHAYMqcuuXdGJBq2+F1M2zolsqXP4OYY6Ea9P2M9XUcdJkGAf9t1PQzAb8Rg EAwA== X-Gm-Message-State: AGi0PuY2Hm3q0DzBzWY1NCiIkna7SpF1pZ2A0ysJfOjeR/1HpOPPdYrs bu5OaUUi+sadIV7NbxLX+dBr0/KnNZ4= X-Received: by 2002:a05:6512:1046:: with SMTP id c6mr2050367lfb.115.1586507753158; Fri, 10 Apr 2020 01:35:53 -0700 (PDT) Received: from [10.68.32.192] (broadband-188-32-231-41.ip.moscow.rt.ru. [188.32.231.41]) by smtp.gmail.com with ESMTPSA id i20sm895855lfe.15.2020.04.10.01.35.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 10 Apr 2020 01:35:52 -0700 (PDT) To: Willy Tarreau Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200331094054.24441-1-w@1wt.eu> <20200331094054.24441-23-w@1wt.eu> From: Denis Efremov Autocrypt: addr=efremov@linux.com; keydata= mQINBFsJUXwBEADDnzbOGE/X5ZdHqpK/kNmR7AY39b/rR+2Wm/VbQHV+jpGk8ZL07iOWnVe1 ZInSp3Ze+scB4ZK+y48z0YDvKUU3L85Nb31UASB2bgWIV+8tmW4kV8a2PosqIc4wp4/Qa2A/ Ip6q+bWurxOOjyJkfzt51p6Th4FTUsuoxINKRMjHrs/0y5oEc7Wt/1qk2ljmnSocg3fMxo8+ y6IxmXt5tYvt+FfBqx/1XwXuOSd0WOku+/jscYmBPwyrLdk/pMSnnld6a2Fp1zxWIKz+4VJm QEIlCTe5SO3h5sozpXeWS916VwwCuf8oov6706yC4MlmAqsQpBdoihQEA7zgh+pk10sCvviX FYM4gIcoMkKRex/NSqmeh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P11aRrs6+qMHSd/s3N3j0hR2Uxsski8q6x+LxU1aHS0FFkSl0m8SiazA Gd1zy4pXC2HhCHstF24Nu5iVLPRwlxFS/+o3nB1ZWTwu8I6s2ZF5TAgBfEONV5MIYH3fOb5+ r/HYPye7puSmQ2LCXy7X5IIsnAoxSrcFYq9nGfHNcXhm5x6WjYC0Kz8l4lfwWo8PIpZ8x57v gTH1PI5R4WdRQijLxLCW/AaiuoEYuOLAoW481XtZb0GRRe+Tm9z/fCbkEveyPiDK7oZahBM7 QdWEEV8mqJoOZ3xxqMlJrxKM9SDF+auB4zWGz5jGzCDAx/0qMUrVn2+v8i4oEKW6IUdV7axW Nk9a+EF5JSTbfv0JBYeSHK3WRklSYLdsMRhaCKhSbwo8Xgn/m6a92fKd3NnObvRe76iIEMSw 60iagNE6AFFzuF/GvoIHb2oDUIX4z+/D0TBWH9ADNptmuE+LZnlPUAAEzRgUFtlN5LtJP8ph Subject: Re: [PATCH 22/23] floppy: cleanup: do not iterate on current_fdc in DMA grab/release functions Message-ID: Date: Fri, 10 Apr 2020 11:35:51 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200331094054.24441-23-w@1wt.eu> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I see a couple of similar cycles in do_floppy_init: for (i = 0; i < N_FDC; i++) { current_fdc = i; memset(&fdc_state[current_fdc], 0, sizeof(*fdc_state)); fdc_state[current_fdc].dtr = -1; fdc_state[current_fdc].dor = 0x4; ... } for (i = 0; i < N_FDC; i++) { current_fdc = i; fdc_state[current_fdc].driver_version = FD_DRIVER_VERSION; ... } On 3/31/20 12:40 PM, Willy Tarreau wrote: > Both floppy_grab_irq_and_dma() and floppy_release_irq_and_dma() used to > iterate on the global variable while setting up or freeing resources. > Now that they exclusively rely on functions which take the fdc as an > argument, so let's not touch the global one anymore. > > Signed-off-by: Willy Tarreau > --- > drivers/block/floppy.c | 39 ++++++++++++++++++++------------------- > 1 file changed, 20 insertions(+), 19 deletions(-) > > diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c > index 8850baa3372a..77bb9a5fcd33 100644 > --- a/drivers/block/floppy.c > +++ b/drivers/block/floppy.c > @@ -4854,6 +4854,8 @@ static void floppy_release_regions(int fdc) > > static int floppy_grab_irq_and_dma(void) > { > + int fdc; > + > if (atomic_inc_return(&usage_count) > 1) > return 0; > > @@ -4881,24 +4883,24 @@ static int floppy_grab_irq_and_dma(void) > } > } > > - for (current_fdc = 0; current_fdc < N_FDC; current_fdc++) { > - if (fdc_state[current_fdc].address != -1) { > - if (floppy_request_regions(current_fdc)) > + for (fdc = 0; fdc < N_FDC; fdc++) { > + if (fdc_state[fdc].address != -1) { > + if (floppy_request_regions(fdc)) > goto cleanup; > } > } > - for (current_fdc = 0; current_fdc < N_FDC; current_fdc++) { > - if (fdc_state[current_fdc].address != -1) { > - reset_fdc_info(current_fdc, 1); > - fdc_outb(fdc_state[current_fdc].dor, current_fdc, FD_DOR); > + for (fdc = 0; fdc < N_FDC; fdc++) { > + if (fdc_state[fdc].address != -1) { > + reset_fdc_info(fdc, 1); > + fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR); > } > } > - current_fdc = 0; > + > set_dor(0, ~0, 8); /* avoid immediate interrupt */ > > - for (current_fdc = 0; current_fdc < N_FDC; current_fdc++) > - if (fdc_state[current_fdc].address != -1) > - fdc_outb(fdc_state[current_fdc].dor, current_fdc, FD_DOR); > + for (fdc = 0; fdc < N_FDC; fdc++) > + if (fdc_state[fdc].address != -1) > + fdc_outb(fdc_state[fdc].dor, fdc, FD_DOR); > /* > * The driver will try and free resources and relies on us > * to know if they were allocated or not. > @@ -4909,15 +4911,16 @@ static int floppy_grab_irq_and_dma(void) > cleanup: > fd_free_irq(); > fd_free_dma(); > - while (--current_fdc >= 0) > - floppy_release_regions(current_fdc); > + while (--fdc >= 0) > + floppy_release_regions(fdc); > + current_fdc = 0; > atomic_dec(&usage_count); > return -1; > } > > static void floppy_release_irq_and_dma(void) > { > - int old_fdc; > + int fdc; > #ifndef __sparc__ > int drive; > #endif > @@ -4958,11 +4961,9 @@ static void floppy_release_irq_and_dma(void) > pr_info("auxiliary floppy timer still active\n"); > if (work_pending(&floppy_work)) > pr_info("work still pending\n"); > - old_fdc = current_fdc; > - for (current_fdc = 0; current_fdc < N_FDC; current_fdc++) > - if (fdc_state[current_fdc].address != -1) > - floppy_release_regions(current_fdc); > - current_fdc = old_fdc; > + for (fdc = 0; fdc < N_FDC; fdc++) > + if (fdc_state[fdc].address != -1) > + floppy_release_regions(fdc); > } > > #ifdef MODULE >