Skip to contentSkip to conversation

scsi: qla1280.c

PATCH In review Magnus Lindholm 4 participants 5 messages Nov 4, 2024 – Nov 6, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 scsi: qla1280.c

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.

---
 drivers/scsi/qla1280.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/scsi/qla1280.c +10 -5
index 8958547ac111..4ba4084bf252 100644
@@ -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;
Signature · 1 line
2.47.0
#1 lore raw
Quoted 5 lines · Magnus Lindholm

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.

Maciej

#2 lore raw
Quoted 11 lines · On Mon, 4 Nov 2024 21:52:36 +0000 (GMT) "Maciej W. Rozycki"…
Quoted 5 lines · Magnus Lindholm

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 ?

Thomas.

Signature · 3 lines
SUSE Software Solutions Germany GmbH
HRB 36809 (AG Nürnberg)
Geschäftsführer: Ivo Totev, Andrew McDonald, Werner Knoblich
#3 lore raw
Quoted 11 lines · Thomas Bogendoerfer
Quoted 8 lines · On Mon, 4 Nov 2024 21:52:36 +0000 (GMT) "Maciej W. Rozycki"…
Quoted 5 lines · Magnus Lindholm

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.

Quoted 8 lines
Quoted 3 lines

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

#4 lore raw
In reply to Magnus Lindholm

Magnus,

Quoted 7 lines
drivers/scsi/qla1280.c +0 -0
index 8958547ac111..4ba4084bf252 100644
@@ -8,9 +8,11 @@
 * Copyright (C) 2003-2004 Christoph Hellwig
 *

drivers/scsi/qla1280.c line 18

Quoted 10 lines
drivers/scsi/qla1280.c +3 -1
 ******************************************************************************/
-#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

Minor nit for your v4:

Now that we have git logs there is no point in updating the version and revision history. We leave the original text there for historic reasons.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering