linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Khalid Aziz <khalid@gonehiking.org>
To: Arnd Bergmann <arnd@kernel.org>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>, Jakub Kicinski <kuba@kernel.org>,
	Christoph Hellwig <hch@infradead.org>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Robin Murphy <robin.murphy@arm.com>,
	iommu@lists.linux-foundation.org,
	"Maciej W . Rozycki" <macro@orcam.me.uk>,
	Matt Wang <wwentao@vmware.com>,
	Miquel van Smoorenburg <mikevs@xs4all.net>,
	Mark Salyzyn <salyzyn@android.com>,
	linuxppc-dev@lists.ozlabs.org, linux-arch@vger.kernel.org,
	linux-alpha@vger.kernel.org, linux-m68k@lists.linux-m68k.org,
	linux-parisc@vger.kernel.org, Denis Efremov <efremov@linux.com>
Subject: Re: [PATCH v2 2/3] scsi: BusLogic remove bus_to_virt
Date: Tue, 21 Jun 2022 15:56:58 -0600	[thread overview]
Message-ID: <7a6df2da-95e8-b2fd-7565-e4b7a51c5b63@gonehiking.org> (raw)
In-Reply-To: <20220617125750.728590-3-arnd@kernel.org>

On 6/17/22 06:57, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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.
> 
> Cc: Maciej W. Rozycki <macro@orcam.me.uk>
> Cc: Matt Wang <wwentao@vmware.com>
> Cc: Khalid Aziz <khalid@gonehiking.org>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   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);

This change looks good enough as workaround to not use bus_to_virt() for 
now. There are two problems I see though. One, I do worry about 
blogic_inbox_to_ccb() returning NULL for ccb which should not happen 
unless the mailbox pointer was corrupted which would indicate a bigger 
problem. Nevertheless a NULL pointer causing kernel panic concerns me. 
How about adding a check before we dereference ccb?

Second, with this patch applied, I am seeing errors from the driver:

=====================
[ 1623.902685]  sdb: sdb1 sdb2
[ 1623.903245] sd 2:0:0:0: [sdb] Attached SCSI disk
[ 1623.911000] scsi2: Illegal CCB #76 status 2 in Incoming Mailbox
[ 1623.911005] scsi2: Illegal CCB #76 status 2 in Incoming Mailbox
[ 1623.911070] scsi2: Illegal CCB #79 status 2 in Incoming Mailbox
[ 1651.458008] scsi2: Warning: Partition Table appears to have Geometry 
256/63 which is
[ 1651.458013] scsi2: not compatible with current BusLogic Host Adapter 
Geometry 255/63
[ 1658.797609] scsi2: Resetting BusLogic BT-958D Failed
[ 1659.533208] sd 2:0:0:0: Device offlined - not ready after error recovery
[ 1659.533331] sd 2:0:0:0: Device offlined - not ready after error recovery
[ 1659.533333] sd 2:0:0:0: Device offlined - not ready after error recovery
[ 1659.533342] sd 2:0:0:0: [sdb] tag#101 FAILED Result: 
hostbyte=DID_TIME_OUT driverbyte=DRIVER_OK cmd_age=35s
[ 1659.533345] sd 2:0:0:0: [sdb] tag#101 CDB: Read(10) 28 00 00 00 00 28 
00 00 10 00
[ 1659.533346] I/O error, dev sdb, sector 40 op 0x0:(READ) flags 0x80700 
phys_seg 1 prio class 0

=================

This is on VirtualBox using emulated BusLogic adapter.

This patch needs more refinement.

Thanks,
Khalid



>   		if (comp_code != BLOGIC_Cn erroneousMD_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


  parent reply	other threads:[~2022-06-21 22:04 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17 12:57 [PATCH v2 0/3] phase out CONFIG_VIRT_TO_BUS Arnd Bergmann
2022-06-17 12:57 ` [PATCH v2 1/3] scsi: dpt_i2o: drop stale VIRT_TO_BUS dependency Arnd Bergmann
2022-06-21  8:43   ` Hannes Reinecke
2022-06-17 12:57 ` [PATCH v2 2/3] scsi: BusLogic remove bus_to_virt Arnd Bergmann
2022-06-17 14:02   ` Robin Murphy
2022-06-21  8:45   ` Hannes Reinecke
2022-06-21 21:56   ` Khalid Aziz [this message]
2022-06-23 14:47     ` Arnd Bergmann
2022-06-24 15:38       ` Khalid Aziz
2022-06-24 15:43         ` Arnd Bergmann
2022-06-17 12:57 ` [PATCH v2 3/3] arch/*/: remove CONFIG_VIRT_TO_BUS Arnd Bergmann
2022-06-18  1:06   ` Michael Schmitz
2022-06-24  9:10     ` Arnd Bergmann
2022-06-26  5:21       ` Michael Schmitz
2022-06-26  8:36         ` Arnd Bergmann
2022-06-27  8:09           ` Michael Schmitz
2022-06-27  8:26     ` Geert Uytterhoeven
2022-06-27 21:12       ` Michael Schmitz
2022-06-28  3:25         ` Michael Schmitz
2022-06-28  7:03           ` Geert Uytterhoeven
2022-06-28 21:03             ` Michael Schmitz
2022-06-28 21:50               ` Arnd Bergmann
2022-06-28 23:09                 ` Michael Schmitz
2022-06-28 23:50                   ` Bart Van Assche
2022-06-29  0:01                     ` Michael Schmitz
2022-06-29  0:14                       ` Michael Schmitz
2022-06-29  6:21                   ` Christoph Hellwig
2022-06-30 19:21                     ` Michael Schmitz
2022-06-30  8:04                   ` David Laight
2022-06-30  9:40                     ` Christophe Leroy
2022-06-30 10:32                       ` David Laight
2022-06-28  7:08           ` Arnd Bergmann
2022-06-28 21:38             ` Michael Schmitz
2022-06-28 21:55               ` Arnd Bergmann
2022-06-28 23:43                 ` Michael Schmitz
2022-06-29  6:25               ` Christoph Hellwig
2022-06-30 19:26                 ` Michael Schmitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7a6df2da-95e8-b2fd-7565-e4b7a51c5b63@gonehiking.org \
    --to=khalid@gonehiking.org \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=efremov@linux.com \
    --cc=hch@infradead.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=kuba@kernel.org \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-m68k@lists.linux-m68k.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=m.szyprowski@samsung.com \
    --cc=macro@orcam.me.uk \
    --cc=mikevs@xs4all.net \
    --cc=robin.murphy@arm.com \
    --cc=salyzyn@android.com \
    --cc=wwentao@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).