Skip to contentSkip to conversation

libata: implement and use DMA mask configuration helper

PATCH In review Tejun Heo 3 participants 10 messages Mar 9, 2007 – Apr 9, 2007

Subsystems (2)
lore
Share & tools
lore

Tejun Heo

author
#0 lore raw

PATCH 1/1 libata: implement and use DMA mask configuration helper

Implement and use DMA mask configuration helper.

---
This function probably belongs to pci layer. Put it in libata with pci_test_bits() for the time being.

 drivers/ata/ahci.c          |   36 +++++----------------
 drivers/ata/libata-core.c   |   70 +++++++++++++++++++++++++++++++++++++++++++
 drivers/ata/libata-sff.c    |    5 +--
 drivers/ata/pata_cs5520.c   |   14 +++-----
 drivers/ata/pata_pdc2027x.c |    6 +---
 drivers/ata/pata_scc.c      |    5 +--
 drivers/ata/pdc_adma.c      |   21 +------------
 drivers/ata/sata_inic162x.c |   14 +-------
 drivers/ata/sata_mv.c       |   36 +---------------------
 drivers/ata/sata_nv.c       |   17 +++-------
 drivers/ata/sata_promise.c  |    5 +--
 drivers/ata/sata_qstor.c    |   50 ++++---------------------------
 drivers/ata/sata_sil.c      |    5 +--
 drivers/ata/sata_sil24.c    |   27 ++---------------
 drivers/ata/sata_sis.c      |    5 +--
 drivers/ata/sata_svw.c      |    5 +--
 drivers/ata/sata_sx4.c      |    5 +--
 drivers/ata/sata_uli.c      |    5 +--
 drivers/ata/sata_via.c      |    5 +--
 drivers/ata/sata_vsc.c      |    5 +--
 include/linux/libata.h      |    2 +
 21 files changed, 115 insertions(+), 228 deletions(-)
drivers/ata/ahci.c +9 -27
index 4242c70..fd9acf3 100644
@@ -1559,39 +1559,21 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
 	struct ahci_host_priv *hpriv = probe_ent->private_data;
 	struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
 	void __iomem *mmio = probe_ent->iomap[AHCI_PCI_BAR];
-	unsigned int i, using_dac;
+	unsigned int i;
+	u64 dma_mask;
 	int rc;
 
 	rc = ahci_reset_controller(mmio, pdev);
 	if (rc)
 		return rc;
 
-	using_dac = hpriv->cap & HOST_CAP_64;
-	if (using_dac &&
-	    !pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
-		rc = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
-		if (rc) {
-			rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
-			if (rc) {
-				dev_printk(KERN_ERR, &pdev->dev,
-					   "64-bit DMA enable failed\n");
-				return rc;
-			}
-		}
-	} else {
-		rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
-		if (rc) {
-			dev_printk(KERN_ERR, &pdev->dev,
-				   "32-bit DMA enable failed\n");
-			return rc;
-		}
-		rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
-		if (rc) {
-			dev_printk(KERN_ERR, &pdev->dev,
-				   "32-bit consistent DMA enable failed\n");
-			return rc;
-		}
-	}
+	dma_mask = DMA_32BIT_MASK;
+	if (hpriv->cap & HOST_CAP_64)
+		dma_mask = DMA_64BIT_MASK;
+
+	rc = pci_configure_dma_masks(pdev, dma_mask, NULL);
+	if (rc)
+		return rc;
 
 	for (i = 0; i < probe_ent->n_ports; i++)
 		ahci_setup_port(&probe_ent->port[i], mmio, i);
drivers/ata/libata-core.c +70 -0

82 lines not on this page · raw message

drivers/ata/libata-sff.c +1 -4
index df9c83b..dfd906c 100644
@@ -839,10 +839,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
 	}
 
 	/* TODO: If we get no DMA mask we should fall back to PIO */
-	rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
-	if (rc)
-		goto err_out;
-	rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
+	rc = pci_configure_dma_masks(pdev, ATA_DMA_MASK, NULL);
 	if (rc)
 		goto err_out;
 
drivers/ata/pata_cs5520.c +5 -9
index 7ef8342..6bddae5 100644
@@ -210,7 +210,7 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
 	u8 pcicfg;
 	void *iomap[5];
 	static struct ata_probe_ent probe[2];
-	int ports = 0;
+	int ports = 0, rc;
 
 	/* IDE port enable bits */
 	pci_read_config_byte(dev, 0x60, &pcicfg);
@@ -230,14 +230,10 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
 		return -ENODEV;
 	}
 	pci_set_master(dev);
-	if (pci_set_dma_mask(dev, DMA_32BIT_MASK)) {
-		printk(KERN_ERR DRV_NAME ": unable to configure DMA mask.\n");
-		return -ENODEV;
-	}
-	if (pci_set_consistent_dma_mask(dev, DMA_32BIT_MASK)) {
-		printk(KERN_ERR DRV_NAME ": unable to configure consistent DMA mask.\n");
-		return -ENODEV;
-	}
+
+	rc = pci_configure_dma_masks(dev, DMA_32BIT_MASK, NULL);
+	if (rc)
+		return rc;
 
 	/* Map IO ports */
 	iomap[0] = devm_ioport_map(&dev->dev, 0x1F0, 8);
drivers/ata/pata_pdc2027x.c +1 -5
index 93bcdad..3ab66fd 100644
@@ -772,11 +772,7 @@ static int __devinit pdc2027x_init_one(struct pci_dev *pdev, const struct pci_de
 	if (rc)
 		return rc;
 
-	rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
-	if (rc)
-		return rc;
-
-	rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
+	rc = pci_configure_dma_masks(pdev, ATA_DMA_MASK, NULL);
 	if (rc)
 		return rc;
 
drivers/ata/pata_scc.c +1 -4
index f3ed141..ee0c533 100644
@@ -1115,10 +1115,7 @@ static int scc_host_init(struct ata_probe_ent *probe_ent)
 
 	probe_ent->n_ports = 1;
 
-	rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
-	if (rc)
-		return rc;
-	rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
+	rc = pci_configure_dma_masks(pdev, ATA_DMA_MASK, NULL);
 	if (rc)
 		return rc;
 
drivers/ata/pdc_adma.c +1 -20
index 5dd3ca8..9448aab 100644
@@ -600,25 +600,6 @@ static void adma_host_init(unsigned int chip_id,
 		adma_reset_engine(ADMA_REGS(mmio_base, port_no));
 }
 
-static int adma_set_dma_masks(struct pci_dev *pdev, void __iomem *mmio_base)
-{
-	int rc;
-
-	rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
-	if (rc) {
-		dev_printk(KERN_ERR, &pdev->dev,
-			"32-bit DMA enable failed\n");
-		return rc;
-	}
-	rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
-	if (rc) {
-		dev_printk(KERN_ERR, &pdev->dev,
-			"32-bit consistent DMA enable failed\n");
-		return rc;
-	}
-	return 0;
-}
-
 static int adma_ata_init_one(struct pci_dev *pdev,
 			     const struct pci_device_id *ent)
 {
@@ -643,7 +624,7 @@ static int adma_ata_init_one(struct pci_dev *pdev,
 		return rc;
 	mmio_base = pcim_iomap_table(pdev)[ADMA_MMIO_BAR];
 
-	rc = adma_set_dma_masks(pdev, mmio_base);
+	rc = pci_configure_dma_masks(pdev, DMA_32BIT_MASK, NULL);
 	if (rc)
 		return rc;
 
drivers/ata/sata_inic162x.c +2 -12
index 6686c22..733d1f4 100644
@@ -682,19 +682,9 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	iomap = pcim_iomap_table(pdev);
 
 	/* Set dma_mask.  This devices doesn't support 64bit addressing. */
-	rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
-	if (rc) {
-		dev_printk(KERN_ERR, &pdev->dev,
-			   "32-bit DMA enable failed\n");
-		return rc;
-	}
-
-	rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
-	if (rc) {
-		dev_printk(KERN_ERR, &pdev->dev,
-			   "32-bit consistent DMA enable failed\n");
+	rc = pci_configure_dma_masks(pdev, DMA_32BIT_MASK, NULL);
+	if (rc)
 		return rc;
-	}
 
 	probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL);
 	hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
drivers/ata/sata_mv.c +1 -35
index 7b73c73..ed07f7a 100644
@@ -581,40 +581,6 @@ static const struct mv_hw_ops mv6xxx_ops = {
  */
 static int msi;	      /* Use PCI msi; either zero (off, default) or non-zero */
 
-
-/* move to PCI layer or libata core? */
-static int pci_go_64(struct pci_dev *pdev)
-{
-	int rc;
-
-	if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
-		rc = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
-		if (rc) {
-			rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
-			if (rc) {
-				dev_printk(KERN_ERR, &pdev->dev,
-					   "64-bit DMA enable failed\n");
-				return rc;
-			}
-		}
-	} else {
-		rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
-		if (rc) {
-			dev_printk(KERN_ERR, &pdev->dev,
-				   "32-bit DMA enable failed\n");
-			return rc;
-		}
-		rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
-		if (rc) {
-			dev_printk(KERN_ERR, &pdev->dev,
-				   "32-bit consistent DMA enable failed\n");
-			return rc;
-		}
-	}
-
-	return rc;
-}
-
 /*
  * Functions
  */
@@ -2349,7 +2315,7 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (rc)
 		return rc;
 
-	rc = pci_go_64(pdev);
+	rc = pci_configure_dma_masks(pdev, DMA_64BIT_MASK, NULL);
 	if (rc)
 		return rc;
 
drivers/ata/sata_nv.c +5 -12
index 388d07f..eb0f877 100644
@@ -1474,7 +1474,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 	u32 bar;
 	void __iomem *base;
 	unsigned long type = ent->driver_data;
-	int mask_set = 0;
+	u64 dma_mask = ATA_DMA_MASK;
 
         // Make sure this is a SATA controller by counting the number of bars
         // (NVIDIA SATA controllers will always have six bars).  Otherwise,
@@ -1499,19 +1499,12 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 	if(type >= CK804 && adma_enabled) {
 		dev_printk(KERN_NOTICE, &pdev->dev, "Using ADMA mode\n");
 		type = ADMA;
-		if(!pci_set_dma_mask(pdev, DMA_64BIT_MASK) &&
-		   !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))
-			mask_set = 1;
+		dma_mask = DMA_64BIT_MASK;
 	}
 
-	if(!mask_set) {
-		rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
-		if (rc)
-			return rc;
-		rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
-		if (rc)
-			return rc;
-	}
+	rc = pci_configure_dma_masks(pdev, dma_mask, NULL);
+	if (rc)
+		return rc;
 
 	rc = -ENOMEM;
 
drivers/ata/sata_promise.c +1 -4
index 2339813..71a05ad 100644
@@ -873,10 +873,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
 	if (rc)
 		return rc;
 
-	rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
-	if (rc)
-		return rc;
-	rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
+	rc = pci_configure_dma_masks(pdev, ATA_DMA_MASK, NULL);
 	if (rc)
 		return rc;
 
drivers/ata/sata_qstor.c +6 -44

68 lines not on this page · raw message

drivers/ata/sata_sil.c +1 -4
index 170d36e..10e3aea 100644
@@ -651,10 +651,7 @@ static int sil_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (rc)
 		return rc;
 
-	rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
-	if (rc)
-		return rc;
-	rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
+	rc = pci_configure_dma_masks(pdev, ATA_DMA_MASK, NULL);
 	if (rc)
 		return rc;
 
drivers/ata/sata_sil24.c +3 -24
index 7e3242e..ad5add7 100644
@@ -1073,30 +1073,9 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	/*
 	 * Configure the device
 	 */
-	if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) {
-		rc = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK);
-		if (rc) {
-			rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
-			if (rc) {
-				dev_printk(KERN_ERR, &pdev->dev,
-					   "64-bit DMA enable failed\n");
-				return rc;
-			}
-		}
-	} else {
-		rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
-		if (rc) {
-			dev_printk(KERN_ERR, &pdev->dev,
-				   "32-bit DMA enable failed\n");
-			return rc;
-		}
-		rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
-		if (rc) {
-			dev_printk(KERN_ERR, &pdev->dev,
-				   "32-bit consistent DMA enable failed\n");
-			return rc;
-		}
-	}
+	rc = pci_configure_dma_masks(pdev, DMA_64BIT_MASK, NULL);
+	if (rc)
+		return rc;
 
 	/* Apply workaround for completion IRQ loss on PCI-X errata */
 	if (probe_ent->port_flags & SIL24_FLAG_PCIX_IRQ_WOC) {
drivers/ata/sata_sis.c +1 -4
index 1879e0c..75c5683 100644
@@ -276,10 +276,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 		return rc;
 	}
 
-	rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
-	if (rc)
-		return rc;
-	rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
+	rc = pci_configure_dma_masks(pdev, ATA_DMA_MASK, NULL);
 	if (rc)
 		return rc;
 
drivers/ata/sata_svw.c +1 -4
index b121195..e83a608 100644
@@ -418,10 +418,7 @@ static int k2_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
 	if (rc)
 		return rc;
 
-	rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
-	if (rc)
-		return rc;
-	rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
+	rc = pci_configure_dma_masks(pdev, ATA_DMA_MASK, NULL);
 	if (rc)
 		return rc;
 
drivers/ata/sata_sx4.c +1 -4
index 1a081c3..29a68a7 100644
@@ -1341,10 +1341,7 @@ static int pdc_sata_init_one (struct pci_dev *pdev, const struct pci_device_id *
 	if (rc)
 		return rc;
 
-	rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
-	if (rc)
-		return rc;
-	rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
+	rc = pci_configure_dma_masks(pdev, ATA_DMA_MASK, NULL);
 	if (rc)
 		return rc;
 
drivers/ata/sata_uli.c +1 -4
index d659ace..bfdb73e 100644
@@ -205,10 +205,7 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 		return rc;
 	}
 
-	rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
-	if (rc)
-		return rc;
-	rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
+	rc = pci_configure_dma_masks(pdev, ATA_DMA_MASK, NULL);
 	if (rc)
 		return rc;
 
drivers/ata/sata_via.c +1 -4
index 598e6a2..1b43062 100644
@@ -565,10 +565,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 			return -ENODEV;
 		}
 
-	rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
-	if (rc)
-		return rc;
-	rc = pci_set_consistent_dma_mask(pdev, ATA_DMA_MASK);
+	rc = pci_configure_dma_masks(pdev, ATA_DMA_MASK, NULL);
 	if (rc)
 		return rc;
 
drivers/ata/sata_vsc.c +1 -4
index 170bad1..675508f 100644
@@ -395,10 +395,7 @@ static int __devinit vsc_sata_init_one (struct pci_dev *pdev, const struct pci_d
 	/*
 	 * Use 32 bit DMA mask, because 64 bit address support is poor.
 	 */
-	rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
-	if (rc)
-		return rc;
-	rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
+	rc = pci_configure_dma_masks(pdev, DMA_32BIT_MASK, NULL);
 	if (rc)
 		return rc;
 
include/linux/libata.h +2 -0
index 065f494..911ac4e 100644
@@ -872,6 +872,8 @@ struct pci_bits {
 extern struct ata_probe_ent *
 ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask);
 extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
+extern int pci_configure_dma_masks(struct pci_dev *pdev, u64 dma_mask,
+				   u64 *configured_mask);
 extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long);
 #endif /* CONFIG_PCI */
 
Signature · 1 line
1.5.0.1
#2 lore raw
In reply to Tejun Heo
Quoted 6 lines · Tejun Heo

Implement and use DMA mask configuration helper.

---
This function probably belongs to pci layer. Put it in libata with pci_test_bits() for the time being.

AFAIK the default DMA mask is always 32-bit. Code (often written by me) that sets it to a 32-bit mask was just paranoia, and not really needed.

Hence, the pci_go_64() function I added, found in #upstream.

Jeff

author
#3 lore raw
Quoted 8 lines · Jeff Garzik
Quoted 6 lines · Tejun Heo

Implement and use DMA mask configuration helper.

---
This function probably belongs to pci layer. Put it in libata with pci_test_bits() for the time being.

Quoted 4 lines

AFAIK the default DMA mask is always 32-bit. Code (often written by me) that sets it to a 32-bit mask was just paranoia, and not really needed.

Hence, the pci_go_64() function I added, found in #upstream.

Cool.

Signature · 1 line
tejun
author
#4 lore raw
In reply to Jeff Garzik
Quoted 8 lines · Jeff Garzik
Quoted 6 lines · Tejun Heo

Implement and use DMA mask configuration helper.

---
This function probably belongs to pci layer. Put it in libata with pci_test_bits() for the time being.

Quoted 4 lines

AFAIK the default DMA mask is always 32-bit. Code (often written by me) that sets it to a 32-bit mask was just paranoia, and not really needed.

Hence, the pci_go_64() function I added, found in #upstream.

It isn't in #upstream yet. Also, at the second thought, there is a problem with pci_go_64(). DMA masks are not reset after driver is detached. Even if the device starts with 32bit DMA masks, after a 64bit enabled driver is attached and detached, the device's DMA masks are 64bit. I'm refreshing new-init-model patchset and keeping pci_configure_dma_masks() for now.

Thanks.

Signature · 1 line
tejun
#5 lore raw
Quoted 11 lines · Tejun Heo
Quoted 10 lines · Jeff Garzik
Quoted 6 lines · Tejun Heo

Implement and use DMA mask configuration helper.

---
This function probably belongs to pci layer. Put it in libata with pci_test_bits() for the time being.

AFAIK the default DMA mask is always 32-bit. Code (often written by me) that sets it to a 32-bit mask was just paranoia, and not really needed.

Quoted 8 lines
Quoted 1 line

Hence, the pci_go_64() function I added, found in #upstream.

It isn't in #upstream yet. Also, at the second thought, there is a problem with pci_go_64(). DMA masks are not reset after driver is detached. Even if the device starts with 32bit DMA masks, after a 64bit enabled driver is attached and detached, the device's DMA masks are 64bit. I'm refreshing new-init-model patchset and keeping pci_configure_dma_masks() for now.

That "problem" has existed since day one, and nobody seems to care :)

I can't think of a single 64-bit-capable driver that restores the masks, and can't think of a single bug report that resulted from it.

Jeff

author
#6 lore raw
Quoted 21 lines · Jeff Garzik
Quoted 11 lines · Tejun Heo
Quoted 10 lines · Jeff Garzik
Quoted 6 lines · Tejun Heo

Implement and use DMA mask configuration helper.

---
This function probably belongs to pci layer. Put it in libata with pci_test_bits() for the time being.

AFAIK the default DMA mask is always 32-bit. Code (often written by me) that sets it to a 32-bit mask was just paranoia, and not really needed.

Quoted 8 lines
Quoted 1 line

Hence, the pci_go_64() function I added, found in #upstream.

It isn't in #upstream yet. Also, at the second thought, there is a problem with pci_go_64(). DMA masks are not reset after driver is detached. Even if the device starts with 32bit DMA masks, after a 64bit enabled driver is attached and detached, the device's DMA masks are 64bit. I'm refreshing new-init-model patchset and keeping pci_configure_dma_masks() for now.

Quoted 4 lines

That "problem" has existed since day one, and nobody seems to care :)

I can't think of a single 64-bit-capable driver that restores the masks, and can't think of a single bug report that resulted from it.

In reality, it shouldn't really matter as unloading and loading different drivers for the same device is extremely rare. Still incorrect tho. Just making pci_enable_device() reset both DMA masks to 32bit should do the trick.

Signature · 1 line
tejun
author
#7 lore raw
In reply to Jeff Garzik
Quoted 21 lines · Jeff Garzik
Quoted 11 lines · Tejun Heo
Quoted 10 lines · Jeff Garzik
Quoted 6 lines · Tejun Heo

Implement and use DMA mask configuration helper.

---
This function probably belongs to pci layer. Put it in libata with pci_test_bits() for the time being.

AFAIK the default DMA mask is always 32-bit. Code (often written by me) that sets it to a 32-bit mask was just paranoia, and not really needed.

Quoted 8 lines
Quoted 1 line

Hence, the pci_go_64() function I added, found in #upstream.

It isn't in #upstream yet. Also, at the second thought, there is a problem with pci_go_64(). DMA masks are not reset after driver is detached. Even if the device starts with 32bit DMA masks, after a 64bit enabled driver is attached and detached, the device's DMA masks are 64bit. I'm refreshing new-init-model patchset and keeping pci_configure_dma_masks() for now.

Quoted 4 lines

That "problem" has existed since day one, and nobody seems to care :)

I can't think of a single 64-bit-capable driver that restores the masks, and can't think of a single bug report that resulted from it.

Jeff, there are further problems with doing pci_go_64() only on devices which support 64bit. pci_set_dma_mask() is the only place where the PCI code can test whether DMA is usable or not, so if we don't configure DMA mask on 32bit controllers, there's no way to tell whether DMA is allowed on the controller/bus or not. We end up blindly enabling bus mastering without consulting the PCI bus.

I think it's just cleaner to do pci_configure_dma_masks() on all cases with proper DMA mask.

Thanks.

Signature · 1 line
tejun
#8 lore raw
Quoted 9 lines · Tejun Heo

Jeff, there are further problems with doing pci_go_64() only on devices which support 64bit. pci_set_dma_mask() is the only place where the PCI code can test whether DMA is usable or not, so if we don't configure DMA mask on 32bit controllers, there's no way to tell whether DMA is allowed on the controller/bus or not. We end up blindly enabling bus mastering without consulting the PCI bus.

I think it's just cleaner to do pci_configure_dma_masks() on all cases with proper DMA mask.

There is always a cleaner solution :)

My implementation is based on current practice for all 64-bit drivers.

If you wish to change current practice, that is another matter...

Jeff

author
#9 lore raw
Quoted 12 lines · Jeff Garzik
Quoted 9 lines · Tejun Heo

Jeff, there are further problems with doing pci_go_64() only on devices which support 64bit. pci_set_dma_mask() is the only place where the PCI code can test whether DMA is usable or not, so if we don't configure DMA mask on 32bit controllers, there's no way to tell whether DMA is allowed on the controller/bus or not. We end up blindly enabling bus mastering without consulting the PCI bus.

I think it's just cleaner to do pci_configure_dma_masks() on all cases with proper DMA mask.

Quoted 5 lines

There is always a cleaner solution :)

My implementation is based on current practice for all 64-bit drivers.

If you wish to change current practice, that is another matter...

The thing is that in the current implementation, we do the following.

1. For 32bit devices, we do set_dma/set_persistent to set 32bit masks manually.

2. For 64bit devices, we do set_dma/set_persistent to set 64bit masks but falls back to 32bit. This is sometimes done manually sometimes using a helper (pci_go_64).

This patch tries to do #1 and #2 in the same way and the end result doesn't change - we're just using the same helper function instead of doing things directly for both 32bit and 64bit cases. Are you suggesting to just generalize pci_go_64 and leave 32bit cases as they are?

Thanks.

Signature · 1 line
tejun