linux-alpha.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] scsi: qla1280: Make 64-bit DMA addressing a Kconfig option
@ 2025-07-28 16:34 Magnus Lindholm
  2025-07-28 16:34 ` [PATCH 1/1] " Magnus Lindholm
  2025-07-31  9:40 ` [PATCH 0/1] " Maciej W. Rozycki
  0 siblings, 2 replies; 7+ messages in thread
From: Magnus Lindholm @ 2025-07-28 16:34 UTC (permalink / raw)
  To: linux-kernel, linux-scsi, linux-alpha, martin.petersen,
	James.Bottomley, hch, macro
  Cc: linmag7

After spending quite some time trying to make the qla1280 driver work
with 64-bit DMA on alpha/tsunami systems with more than 2GB RAM, I
haven't given up on finding the root cause why this doesn't work but
I propose making 32/64 bit optional in the kernel config. Many thanks
to Martin, James, Maciej, Thomas and Christoph who has take the time
to provide feedback and testing during my attempts.

Some platforms like for example the SGI Octace2, require full 64-bit
addressing in order for the qla1280 driver to work. On other systems,
like the tsunami based Alpha systems, 32-bit PCI Qlogic SCSI controllers
(like the ISP1040 series) will not work properly on systems with more
than 2GB RAM installed. For some reason the combination of using PCI DAC
cycles and the enabling the DMA "monster window" on the tsunami based
alphas will result in file system corruption with the Qlogic ISP driver.
This is not the case on other alpha systems, such as rawhide based
systems, like the Alphaserver 4100, on this platform cards like
the qlogic 32-bit PCI (ISP1040B) works fine with PCI DAC cycles and
the "monster window" enabled. In order for the qla1280 driver to work
with ISP1040 chips on tsunami based alphas the driver must be compiled
with 32-bit DMA addressing. Most SRM firmware versions allow alphas to
boot from Qlogic ISP1040 SCSI controllers and hence having a simple way
to limit DMA addressing to 32-bits is relevant.

 drivers/scsi/Kconfig   | 17 +++++++++++++++++
 drivers/scsi/qla1280.c |  2 ++
 2 files changed, 19 insertions(+)

-- 
2.49.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/1] scsi: qla1280: Make 64-bit DMA addressing a Kconfig option
  2025-07-28 16:34 [PATCH 0/1] scsi: qla1280: Make 64-bit DMA addressing a Kconfig option Magnus Lindholm
@ 2025-07-28 16:34 ` Magnus Lindholm
  2025-07-29  7:32   ` Christoph Hellwig
  2025-07-31  9:40 ` [PATCH 0/1] " Maciej W. Rozycki
  1 sibling, 1 reply; 7+ messages in thread
From: Magnus Lindholm @ 2025-07-28 16:34 UTC (permalink / raw)
  To: linux-kernel, linux-scsi, linux-alpha, martin.petersen,
	James.Bottomley, hch, macro
  Cc: linmag7

Make 64-bit DMA addressing a Kconfig option.

While defaulting to 64-bit addressing, this gives the user the option
to revert to 32-bits when necessary without messing with the kernel
source. The Kconfig help text also points out the issues with tsunami
based alphas with more than 2GB RAM and 32-bit PCI Qlogic SCSI
controllers.

Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
---
 drivers/scsi/Kconfig   | 17 +++++++++++++++++
 drivers/scsi/qla1280.c |  2 ++
 2 files changed, 19 insertions(+)

diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 5522310bab8d..27cf94f374f4 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1126,6 +1126,23 @@ config SCSI_QLOGIC_1280
 	  To compile this driver as a module, choose M here: the
 	  module will be called qla1280.
 
+config SCSI_QLOGIC_1280_DMA_64BIT_ADDRESSING
+        bool "Enable 64-bit DMA addressing mode"
+        depends on SCSI_QLOGIC_1280
+        default y
+        help
+	  This options enables full 64-bit addressing for Qlogic ISP
+	  chips. 64-bit addressing works on most platforms and is hence
+	  the default. Some platforms like for example the SGI Octace2,
+	  require full 64-bit addressing in order to work and must have
+	  this option enabled.
+
+	  On some systems, like tsunami based Alpha systems, 32-bit
+	  PCI Qlogic SCSI controllers will not work propberly on systems
+	  with more than 2GB RAM installed. If you are on a tsunami
+	  based alpha (like the ES40, DS20) and want to use cards with
+	  the ISP1040/1020 chip, you should say no here.
+
 config SCSI_QLOGICPTI
 	tristate "PTI Qlogic, ISP Driver"
 	depends on SBUS && SCSI
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 6af018f1ca22..d02141157abe 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -371,8 +371,10 @@
 #include "qla1280.h"
 
 #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
+#ifdef CONFIG_SCSI_QLOGIC_1280_DMA_64BIT_ADDRESSING
 #define QLA_64BIT_PTR	1
 #endif
+#endif
 
 #define NVRAM_DELAY()			udelay(500)	/* 2 microseconds */
 
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] scsi: qla1280: Make 64-bit DMA addressing a Kconfig option
  2025-07-28 16:34 ` [PATCH 1/1] " Magnus Lindholm
@ 2025-07-29  7:32   ` Christoph Hellwig
  2025-07-29  8:58     ` Magnus Lindholm
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2025-07-29  7:32 UTC (permalink / raw)
  To: Magnus Lindholm
  Cc: linux-kernel, linux-scsi, linux-alpha, martin.petersen,
	James.Bottomley, hch, macro

On Mon, Jul 28, 2025 at 06:34:14PM +0200, Magnus Lindholm wrote:
> Make 64-bit DMA addressing a Kconfig option.
> 
> While defaulting to 64-bit addressing, this gives the user the option
> to revert to 32-bits when necessary without messing with the kernel
> source. The Kconfig help text also points out the issues with tsunami
> based alphas with more than 2GB RAM and 32-bit PCI Qlogic SCSI
> controllers.

Compile time options like this are annoying as they require
distributions to pick a default.  Why not at least a module option
even if it just a workaround?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] scsi: qla1280: Make 64-bit DMA addressing a Kconfig option
  2025-07-29  7:32   ` Christoph Hellwig
@ 2025-07-29  8:58     ` Magnus Lindholm
  0 siblings, 0 replies; 7+ messages in thread
From: Magnus Lindholm @ 2025-07-29  8:58 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-kernel, linux-scsi, linux-alpha, martin.petersen,
	James.Bottomley, macro

On Tue, Jul 29, 2025 at 9:32 AM Christoph Hellwig <hch@infradead.org> wrote:

>
> Compile time options like this are annoying as they require
> distributions to pick a default.  Why not at least a module option
> even if it just a workaround?

I see your point, I've been looking at how the driver for the NCR53C8XX
SYM53C8XX family of PCI-SCSI controllers does things. The driver
has a SCSI_SYM53C8XX_DMA_ADDRESSING_MOD compile time
option for setting DMA parameters.

The qla1280 driver has different code for 32-bit and 64-bit mode of
the driver, implying that 32 or 64 bit modes need to be selected at
compile time.

However, it would work just using the 64-bit version
of the driver but, while defaulting to a 64-bit DMA bit mask, making
it possible to limit the DMA bit mask to 32-bit via a kernel module
option. This would make it possible to avoid using the
"monster window" for DMA transfers on tsunami based Alphas.
If the driver is built in 32-bit mode, this module option would simply
have no effect.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/1] scsi: qla1280: Make 64-bit DMA addressing a Kconfig option
  2025-07-28 16:34 [PATCH 0/1] scsi: qla1280: Make 64-bit DMA addressing a Kconfig option Magnus Lindholm
  2025-07-28 16:34 ` [PATCH 1/1] " Magnus Lindholm
@ 2025-07-31  9:40 ` Maciej W. Rozycki
  2025-08-05  8:52   ` Magnus Lindholm
  1 sibling, 1 reply; 7+ messages in thread
From: Maciej W. Rozycki @ 2025-07-31  9:40 UTC (permalink / raw)
  To: Magnus Lindholm
  Cc: linux-kernel, linux-scsi, linux-alpha, martin.petersen,
	James.Bottomley, hch

On Mon, 28 Jul 2025, Magnus Lindholm wrote:

> Some platforms like for example the SGI Octace2, require full 64-bit
> addressing in order for the qla1280 driver to work. On other systems,
> like the tsunami based Alpha systems, 32-bit PCI Qlogic SCSI controllers
> (like the ISP1040 series) will not work properly on systems with more
> than 2GB RAM installed. For some reason the combination of using PCI DAC
> cycles and the enabling the DMA "monster window" on the tsunami based
> alphas will result in file system corruption with the Qlogic ISP driver.
> This is not the case on other alpha systems, such as rawhide based
> systems, like the Alphaserver 4100, on this platform cards like
> the qlogic 32-bit PCI (ISP1040B) works fine with PCI DAC cycles and
> the "monster window" enabled. In order for the qla1280 driver to work
> with ISP1040 chips on tsunami based alphas the driver must be compiled
> with 32-bit DMA addressing. Most SRM firmware versions allow alphas to
> boot from Qlogic ISP1040 SCSI controllers and hence having a simple way
> to limit DMA addressing to 32-bits is relevant.

 Given the description it seems to me it will best be handled as a quirk 
in arch/alpha/kernel/pci.c, at least in the interim.

 If it turns out a generic issue with DAC handling in the Tsunami chipset, 
then a better approach would be a generic workaround for all potentially 
affected devices, but it does not appear we have existing infrastructure 
for that.  Just setting the global DMA mask would unnecessarily cripple 
64-bit option cards as well, but it seems to me there might be something 
relevant in arch/mips/pci/fixup-sb1250.c; see `quirk_sb1250_pci_dac' and 
the comments above it.

 The situation is a bit different here as the bus is a proper 64-bit one, 
but the quirk could only limit the individual DMA mask to 32 bits for 
devices that have no 64-bit memory BARs.  I suspect there are no proper 
64-bit PCI option cards that only have I/O bars and I don't think there's 
any explicit status bit to tell 32-bit and 64-bit option cards apart.

 FWIW I was able to obtain such an option card and try it with my HiFive 
Unmatched RISC-V system, which has 16GiB of RAM.  It turned out picky 
though and despite being DEC-branded it refused to talk to a number of 
SCSI 1 CCS DEC disks, which work just fine with an Adaptec host adapter 
using the same cables and with DECstation systems they came with, but also 
break with a BusLogic MultiMaster host adapter (which seems odd as these 
host adapters have been reputably very robust).

 So I could only do limited testing with a single SCSI 2 disk that works 
everywhere, and that triggered no issues.  As I wanted to retain remote 
access to said problematic disks from the Unmatched machine I have left 
them wired to the Adaptec device, but I'll see if I can do more testing at 
my next visit to the lab around the weekend after next as I'm going to 
disassemble the Unmatched system anyway.

 HTH,

  Maciej

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/1] scsi: qla1280: Make 64-bit DMA addressing a Kconfig option
  2025-07-31  9:40 ` [PATCH 0/1] " Maciej W. Rozycki
@ 2025-08-05  8:52   ` Magnus Lindholm
  2025-09-01 21:41     ` Magnus Lindholm
  0 siblings, 1 reply; 7+ messages in thread
From: Magnus Lindholm @ 2025-08-05  8:52 UTC (permalink / raw)
  To: Maciej W. Rozycki
  Cc: linux-kernel, linux-scsi, linux-alpha, martin.petersen,
	James.Bottomley, hch

On Thu, Jul 31, 2025 at 11:49 AM Maciej W. Rozycki <macro@orcam.me.uk> wrote:
ng a simple way
> > to limit DMA addressing to 32-bits is relevant.
>
>  Given the description it seems to me it will best be handled as a quirk
> in arch/alpha/kernel/pci.c, at least in the interim.
>
>  If it turns out a generic issue with DAC handling in the Tsunami chipset,
> then a better approach would be a generic workaround for all potentially
> affected devices, but it does not appear we have existing infrastructure
> for that.  Just setting the global DMA mask would unnecessarily cripple
> 64-bit option cards as well, but it seems to me there might be something
> relevant in arch/mips/pci/fixup-sb1250.c; see `quirk_sb1250_pci_dac' and
> the comments above it.
>
>  The situation is a bit different here as the bus is a proper 64-bit one,
> but the quirk could only limit the individual DMA mask to 32 bits for
> devices that have no 64-bit memory BARs.  I suspect there are no proper
> 64-bit PCI option cards that only have I/O bars and I don't think there's
> any explicit status bit to tell 32-bit and 64-bit option cards apart.
>

This approach would probably also work. This would mean limiting
32-bit PCI cards from using DAC/monster window DMA on Tsunami based
Alphas. In practice, I believe that there are very few 32-bit PCI cards that
are likely to be used on Alphas that have drivers which support 64-bit DMA
addressing. The only example I've found so far is the qla1280 driver.

Since not all tsunami based Alphas support more than 2GB RAM there are
even fewer examples where this will be a real problem. I'm not 100% sure
that there is a generic issue with DAC handling in the Tsunami chipset but
I'm suspecting that there is. I think that for DS20/ES40 systems using
Qlogic ISP1040 SCSI controllers would be the most likely (maybe the only)
real use case that I can think of.

I can put together a v2 patch based on  a similar approach as
`quirk_sb1250_pci_dac' mentioned above, if this is a better approach
than limiting the DMA mask on only the qlogic driver (by using a module option)

Regards

Magnus

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/1] scsi: qla1280: Make 64-bit DMA addressing a Kconfig option
  2025-08-05  8:52   ` Magnus Lindholm
@ 2025-09-01 21:41     ` Magnus Lindholm
  0 siblings, 0 replies; 7+ messages in thread
From: Magnus Lindholm @ 2025-09-01 21:41 UTC (permalink / raw)
  To: Maciej W. Rozycki
  Cc: linux-kernel, linux-scsi, linux-alpha, martin.petersen,
	James.Bottomley, hch

Hi,

> >  If it turns out a generic issue with DAC handling in the Tsunami chipset,
> > then a better approach would be a generic workaround for all potentially
> > affected devices, but it does not appear we have existing infrastructure
> > for that.  Just setting the global DMA mask would unnecessarily cripple
> > 64-bit option cards as well, but it seems to me there might be something
> > relevant in arch/mips/pci/fixup-sb1250.c; see `quirk_sb1250_pci_dac' and
> > the comments above it.

I've been taking a closer look at the quirk_sb1250_pci_dac. It should indeed
be possible to implement a similar workaround on Alpha. I believe that would
require some fixes to the Alpha specific implementations in pci_iommu.c. For
one thing, the implementation does not respect 'dev->bus_dma_limit' which
is used in  the quirk_sb1250_pci_dac implementation.

I've put together a patch, and I'm testing it right now, that implements a quirk
similar to quirk_sb1250_pci_dac as well as makes stuff in pci_iommu.c take
'dev->bus_dma_limit' into consideration on Alpha. If this approach makes
sense I'll put out a new patch for review. Since this approach does not
touch the qla1280 SCSI driver, I won't send it to the linux-scsi list.

Regards

Magnus

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-09-01 21:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-28 16:34 [PATCH 0/1] scsi: qla1280: Make 64-bit DMA addressing a Kconfig option Magnus Lindholm
2025-07-28 16:34 ` [PATCH 1/1] " Magnus Lindholm
2025-07-29  7:32   ` Christoph Hellwig
2025-07-29  8:58     ` Magnus Lindholm
2025-07-31  9:40 ` [PATCH 0/1] " Maciej W. Rozycki
2025-08-05  8:52   ` Magnus Lindholm
2025-09-01 21:41     ` Magnus Lindholm

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).