Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp482295iog; Fri, 17 Jun 2022 07:16:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uKib+xzQSt3S45dMNeqx2WMc9Mt+504/HtGOUCsA6CWhL2TU8DMpJRccVf//3YpPSzc0et X-Received: by 2002:a17:907:3e1d:b0:711:dc92:e308 with SMTP id hp29-20020a1709073e1d00b00711dc92e308mr9466891ejc.235.1655475405929; Fri, 17 Jun 2022 07:16:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655475405; cv=none; d=google.com; s=arc-20160816; b=LFwcXpo2vSiYywWdxw3MpPqAQ628qXZKzNAFAHz1XPpZXs+YvgTJ8Wifr8Shl/j8RO KmLWDPuH3P6HX4TO7FOpI8jJQqJ6zQpQVoJjey/4tUbR9CAl1zWvpPJWf6zXYnldKvk9 CltyPQVs57KxWogT9rkhakVspRpDUlxnZI9U0jKiCK/inh1uHqWKwbVUZWOhMbwL6o5/ ouKh+OvP24/EV9oqbJBdjgxIdSKDrvKhg8kjwQ8FFe+EV1EPpQkY7rm6Aoyz/oFgn0M+ Rp3UeKi1IRQYJeh69ut2CHYkVgic42x0g1pKiDsxoyzVdMzxfc3UC4mfH5OeIUviyl4e CtJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=pmQcGsxewGBbN4JNTiAgGUuEYs+hoWyd7dP5BBYJaok=; b=O57FnTt1rGeaLd/4PZKLTKFVOS3OJG9FnfsWGe+LCvhcYRe/dH1f8DCgxtZQaO5KKn NZHpGdquWpTKz2Nh45koB9XGpSLXw02SnPVmSYq5UIKu2cnJ2hdLHvWetc8UtI3Xo/6o Cw3aNOkpLAIPrGqLLPiEm9YRhJQpdFOm5KpE6p9EyLiOTy8jgFEopT1BMLyjBJZSmAtF m1OlYQtAsiYNUlar5hB/bAJX6jYpFJRx7A2psmbrTAHukQTypdqpyiK2erNi/fJgkKBY quGHga1tIKWljbEl7dAsddnoT+haeQiuVZ+lbJVEUWB5j94Gjl11A+09Qjdyl38yuX36 UVDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b12-20020a056402278c00b00425992205e5si1063322ede.346.2022.06.17.07.16.20; Fri, 17 Jun 2022 07:16:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382595AbiFQOCk (ORCPT + 99 others); Fri, 17 Jun 2022 10:02:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382551AbiFQOCh (ORCPT ); Fri, 17 Jun 2022 10:02:37 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A102F2BC9; Fri, 17 Jun 2022 07:02:36 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3CA0712FC; Fri, 17 Jun 2022 07:02:36 -0700 (PDT) Received: from [10.57.84.65] (unknown [10.57.84.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 40BA13F7D8; Fri, 17 Jun 2022 07:02:33 -0700 (PDT) Message-ID: Date: Fri, 17 Jun 2022 15:02:27 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v2 2/3] scsi: BusLogic remove bus_to_virt Content-Language: en-GB To: Arnd Bergmann , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, Miquel van Smoorenburg , linux-parisc@vger.kernel.org, Arnd Bergmann , linuxppc-dev@lists.ozlabs.org, "Maciej W . Rozycki" , linux-m68k@lists.linux-m68k.org, Denis Efremov , Mark Salyzyn , Christoph Hellwig , iommu@lists.linux-foundation.org, Matt Wang , linux-alpha@vger.kernel.org, Jakub Kicinski , Khalid Aziz References: <20220617125750.728590-1-arnd@kernel.org> <20220617125750.728590-3-arnd@kernel.org> From: Robin Murphy In-Reply-To: <20220617125750.728590-3-arnd@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-06-17 13:57, Arnd Bergmann wrote: > From: Arnd Bergmann > > The BusLogic driver is the last remaining driver that relies on the > deprecated bus_to_virt() function, which in turn only works on a few > architectures, and is incompatible with both swiotlb and iommu support. > > Before commit 391e2f25601e ("[SCSI] BusLogic: Port driver to 64-bit."), > the driver had a dependency on x86-32, presumably because of this > problem. However, the change introduced another bug that made it still > impossible to use the driver on any 64-bit machine. > > This was in turn fixed in commit 56f396146af2 ("scsi: BusLogic: Fix > 64-bit system enumeration error for Buslogic"), 8 years later, which > shows that there are not a lot of users. > > Maciej is still using the driver on 32-bit hardware, and Khalid mentioned > that the driver works with the device emulation used in VirtualBox > and VMware. Both of those only emulate it for Windows 2000 and older > operating systems that did not ship with the better LSI logic driver. > > Do a minimum fix that searches through the list of descriptors to find > one that matches the bus address. This is clearly as inefficient as > was indicated in the code comment about the lack of a bus_to_virt() > replacement. A better fix would likely involve changing out the entire > descriptor allocation for a simpler one, but that would be much > more invasive. FWIW, if efficiency *is* a practical concern, even under the current allocation scheme it looks like there are only 4 actual DMA allocations to search through. From a quick scan (since it's too hot here not to get distracted...), if I wanted to optimise this in future I'd probably remove the semi-redundant allocgrp_* fields from struct blogic_ccb and hang a dedicated list of the block allocations off the adapter - at that point the lookup could likely already be more efficient than a theoretical dma_to_virt() interface would be if it had to go off and walk an IOMMU pagetable. Then the next question would be whether it's viable to make a single 32KB allocation rather 4*8KB, so it's no longer even a list. For now, though, I agree with the simple change that's clear and easy to reason about: Reviewed-by: Robin Murphy Thanks, Robin. > Cc: Maciej W. Rozycki > Cc: Matt Wang > Cc: Khalid Aziz > Signed-off-by: Arnd Bergmann > --- > drivers/scsi/BusLogic.c | 27 ++++++++++++++++----------- > drivers/scsi/Kconfig | 2 +- > 2 files changed, 17 insertions(+), 12 deletions(-) > > diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c > index a897c8f914cf..d057abfcdd5c 100644 > --- a/drivers/scsi/BusLogic.c > +++ b/drivers/scsi/BusLogic.c > @@ -2515,12 +2515,26 @@ static int blogic_resultcode(struct blogic_adapter *adapter, > return (hoststatus << 16) | tgt_status; > } > > +/* > + * turn the dma address from an inbox into a ccb pointer > + * This is rather inefficient. > + */ > +static struct blogic_ccb * > +blogic_inbox_to_ccb(struct blogic_adapter *adapter, struct blogic_inbox *inbox) > +{ > + struct blogic_ccb *ccb; > + > + for (ccb = adapter->all_ccbs; ccb; ccb = ccb->next_all) > + if (inbox->ccb == ccb->dma_handle) > + break; > + > + return ccb; > +} > > /* > blogic_scan_inbox scans the Incoming Mailboxes saving any > Incoming Mailbox entries for completion processing. > */ > - > static void blogic_scan_inbox(struct blogic_adapter *adapter) > { > /* > @@ -2540,16 +2554,7 @@ static void blogic_scan_inbox(struct blogic_adapter *adapter) > enum blogic_cmplt_code comp_code; > > while ((comp_code = next_inbox->comp_code) != BLOGIC_INBOX_FREE) { > - /* > - We are only allowed to do this because we limit our > - architectures we run on to machines where bus_to_virt( > - actually works. There *needs* to be a dma_addr_to_virt() > - in the new PCI DMA mapping interface to replace > - bus_to_virt() or else this code is going to become very > - innefficient. > - */ > - struct blogic_ccb *ccb = > - (struct blogic_ccb *) bus_to_virt(next_inbox->ccb); > + struct blogic_ccb *ccb = blogic_inbox_to_ccb(adapter, adapter->next_inbox); > if (comp_code != BLOGIC_CMD_NOTFOUND) { > if (ccb->status == BLOGIC_CCB_ACTIVE || > ccb->status == BLOGIC_CCB_RESET) { > diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig > index cf75588a2587..56bdc08d0b77 100644 > --- a/drivers/scsi/Kconfig > +++ b/drivers/scsi/Kconfig > @@ -513,7 +513,7 @@ config SCSI_HPTIOP > > config SCSI_BUSLOGIC > tristate "BusLogic SCSI support" > - depends on PCI && SCSI && VIRT_TO_BUS > + depends on PCI && SCSI > help > This is support for BusLogic MultiMaster and FlashPoint SCSI Host > Adapters. Consult the SCSI-HOWTO, available from