diff mbox series

[v3] scsi: qla1280.c

Message ID 20241104204845.1785-1-linmag7@gmail.com
State New
Headers show
Series [v3] scsi: qla1280.c | expand

Commit Message

Magnus Lindholm Nov. 4, 2024, 8:46 p.m. UTC
Use dma_get_required_mask() to determine an acceptable DMA_BIT_MASK 
 since on some platforms, qla1040 cards do not work with a 64-bit
 mask. For example, on alpha systems with more than 2GB ram a 64-bit DMA mask
 will result in filesystem corruption, but a 64-bit mask is required on
 IP30/MIPS.

Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
---
 drivers/scsi/qla1280.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Maciej W. Rozycki Nov. 6, 2024, 12:48 p.m. UTC | #1
On Tue, 5 Nov 2024, Thomas Bogendoerfer wrote:

> On Mon, 4 Nov 2024 21:52:36 +0000 (GMT)
> "Maciej W. Rozycki" <macro@orcam.me.uk> wrote:
> 
> > On Mon, 4 Nov 2024, Magnus Lindholm wrote:
> > 
> > >  Use dma_get_required_mask() to determine an acceptable DMA_BIT_MASK 
> > >  since on some platforms, qla1040 cards do not work with a 64-bit
> > >  mask. For example, on alpha systems with more than 2GB ram a 64-bit DMA mask
> > >  will result in filesystem corruption, but a 64-bit mask is required on
> > >  IP30/MIPS.  
> > 
> >  This is missing the point, you get filesystem corruption because *your 
> > card* does not support 64-bit DMA addressing and not because your Alpha 
> > system has an issue with it.
> 
> I've checked one of my Octane boards and there are ISP1040B chips on
> the board, so even ISP1040B is able to address 64bits.
> 
> How does the memory map look for more and 2GB ram on the ES40 ?

 Memory is added linearly from 0 up to 32GiB in the host address space, 
but that that's not how it's addressed from the PCI side by DMA masters.  
Here's how Linux sets up PCI DMA decoding windows with the Tsunami/Typhoon 
chipset:

	 * Note: Window 3 is scatter-gather only
	 *
	 * Window 0 is scatter-gather 8MB at 8MB (for isa)
	 * Window 1 is scatter-gather (up to) 1GB at 1GB
	 * Window 2 is direct access 2GB at 2GB

(window 3 is not enabled by Linux).  Windows 0-2 decode up to 2GiB each 
anywhere in the 32-bit PCI DMA address space and map to memory anywhere in 
the host 32GiB address space (SG requests do this via IOMMU).  Window 3 
can work the same as windows 0-2 or decode 4GiB anywhere in the low 32GiB 
of the PCI DMA address space.  The monster window previously mentioned 
maps 32GiB of host address space directly at 1TiB in the PCI DMA address 
space.

  Maciej
diff mbox series

Patch

diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 8958547ac111..4ba4084bf252 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -8,9 +8,11 @@ 
 * Copyright (C) 2003-2004 Christoph Hellwig
 *
 ******************************************************************************/
-#define QLA1280_VERSION      "3.27.1"
+#define QLA1280_VERSION      "3.27.2"
 /*****************************************************************************
     Revision History:
+    Rev  3.27.2, November 3, 2024, Magnus Lindholm
+	- Use dma_get_required_mask() to determine DMA_BIT_MASK if QLA_64BIT_PTR
     Rev  3.27.1, February 8, 2010, Michael Reed
 	- Retain firmware image for error recovery.
     Rev  3.27, February 10, 2009, Michael Reed
@@ -4143,6 +4145,8 @@  qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 	struct Scsi_Host *host;
 	struct scsi_qla_host *ha;
 	int error = -ENODEV;
+	/* use 32-bit mask as default in case driver is built for 32-only */
+	u64 required_mask = DMA_BIT_MASK(32);
 
 	/* Bypass all AMI SUBSYS VENDOR IDs */
 	if (pdev->subsystem_vendor == PCI_VENDOR_ID_AMI) {
@@ -4177,7 +4181,8 @@  qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 	ha->devnum = devnum;	/* specifies microcode load address */
 
 #ifdef QLA_64BIT_PTR
-	if (dma_set_mask_and_coherent(&ha->pdev->dev, DMA_BIT_MASK(64))) {
+	required_mask = dma_get_required_mask(&ha->pdev->dev);
+	if (dma_set_mask_and_coherent(&ha->pdev->dev, required_mask)) {
 		if (dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32))) {
 			printk(KERN_WARNING "scsi(%li): Unable to set a "
 			       "suitable DMA mask - aborting\n", ha->host_no);
@@ -4185,10 +4190,10 @@  qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 			goto error_put_host;
 		}
 	} else
-		dprintk(2, "scsi(%li): 64 Bit PCI Addressing Enabled\n",
-			ha->host_no);
+		dprintk(2, "scsi(%li): %d-bit PCI Addressing Enabled\n",
+			ha->host_no, fls64(required_mask));
 #else
-	if (dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32))) {
+	if (dma_set_mask(&ha->pdev->dev, required_mask)) {
 		printk(KERN_WARNING "scsi(%li): Unable to set a "
 		       "suitable DMA mask - aborting\n", ha->host_no);
 		error = -ENODEV;