libata dma_set_mask cleanups
Subsystems (2)
Hi all,
this series makes use of the fact that dma_set_mask now never fails for a larger than necessary DMA mask, and cleans up various other bits around dma mask setting.
PATCH 1/8 acard_ahci: use dma_set_mask_and_coherent
Use the dma_set_mask_and_coherent helper to set the DMA mask. Rely on the relatively recent change that setting a larger than required mask will never fail to avoid the need for the boilerplate 32-bit fallback code.
--- drivers/ata/acard-ahci.c | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-)
drivers/ata/acard-ahci.c +5 -33
@@ -160,37 +160,6 @@ static int acard_ahci_pci_device_resume(struct pci_dev *pdev) }#endif -static int acard_ahci_configure_dma_masks (struct pci_dev *pdev,int using_dac) -{ -int rc; - -if (using_dac && - !dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 ))) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); -if (rc) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev, -"64-bit DMA enable failed\n" ); -return rc; - } - } - }else { - rc =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev,"32-bit DMA enable failed\n" ); -return rc; - } - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev, -"32-bit consistent DMA enable failed\n" ); -return rc; - } - } -return 0 ; -} -static void acard_ahci_pci_print_info (struct ata_host *host) {struct pci_dev *pdev =to_pci_dev (host->dev);
@@ -472,9 +441,12 @@ static int acard_ahci_init_one(struct pci_dev *pdev, const struct pci_device_id }/* initialize adapter */ - rc =acard_ahci_configure_dma_masks (pdev, hpriv->cap &HOST_CAP_64 ); -if (rc) + rc =dma_set_mask_and_coherent (&pdev->dev, +DMA_BIT_MASK ((hpriv->cap &HOST_CAP_64 ) ?64 :32 )); +if (rc) { +dev_err (&pdev->dev,"DMA enable failed\n" );return rc; + } rc =ahci_reset_controller (host);if (rc)
Signature · 1 line
2.20.1
PATCH 2/8 ahci: use dma_set_mask_and_coherent
In reply to Christoph HellwigUse the dma_set_mask_and_coherent helper to set the DMA mask. Rely on the relatively recent change that setting a larger than required mask will never fail to avoid the need for the boilerplate 32-bit fallback code.
--- drivers/ata/ahci.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-)
drivers/ata/ahci.c +8 -25
@@ -901,40 +901,23 @@ static int ahci_pci_device_resume(struct device *dev)static int ahci_configure_dma_masks (struct pci_dev *pdev,int using_dac) { +const int dma_bits = using_dac ?64 :32 ;int rc;/* * If the device fixup already set the dma_mask to some non-standard * value, don't extend it here. This happens on STA2X11, for example. +* +* XXX: manipulating the DMA mask from platform code is completely +* bogus, platform code should use dev->bus_dma_mask instead.. */ if (pdev->dma_mask && pdev->dma_mask <DMA_BIT_MASK (32 ))return 0 ; -if (using_dac && - !dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 ))) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); -if (rc) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev, -"64-bit DMA enable failed\n" ); -return rc; - } - } - }else { - rc =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev,"32-bit DMA enable failed\n" ); -return rc; - } - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev, -"32-bit consistent DMA enable failed\n" ); -return rc; - } - } -return 0 ; + rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (dma_bits)); +if (rc) +dev_err (&pdev->dev,"DMA enable failed\n" ); +return rc; }static void ahci_pci_print_info (struct ata_host *host)
Signature · 1 line
2.20.1
PATCH 3/8 pdc_adma: use dma_set_mask_and_coherent
In reply to Christoph HellwigUse the dma_set_mask_and_coherent helper to set the DMA mask. Rely on the relatively recent change that setting a larger than required mask will never fail to avoid the need for the boilerplate 32-bit fallback code.
--- drivers/ata/pdc_adma.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-)
drivers/ata/pdc_adma.c +4 -19
@@ -573,23 +573,6 @@ static void adma_host_init(struct ata_host *host, unsigned int chip_id)adma_reset_engine (host->ports[port_no]); } -static int adma_set_dma_masks (struct pci_dev *pdev,void __iomem *mmio_base) -{ -int rc; - - rc =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev,"32-bit DMA enable failed\n" ); -return rc; - } - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_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) {
@@ -620,9 +603,11 @@ static int adma_ata_init_one(struct pci_dev *pdev, host->iomap =pcim_iomap_table (pdev); mmio_base = host->iomap[ADMA_MMIO_BAR ]; - rc =adma_set_dma_masks (pdev, mmio_base); -if (rc) + rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 )); +if (rc) { +dev_err (&pdev->dev,"32-bit DMA enable failed\n" );return rc; + }for (port_no =0 ; port_no <ADMA_PORTS ; ++port_no) {struct ata_port *ap = host->ports[port_no];
Signature · 1 line
2.20.1
PATCH 4/8 sata_mv: use dma_set_mask_and_coherent
In reply to Christoph HellwigUse the dma_set_mask_and_coherent helper to set the DMA mask. Rely on the relatively recent change that setting a larger than required mask will never fail to avoid the need for the boilerplate 32-bit fallback code.
--- drivers/ata/sata_mv.c | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-)
drivers/ata/sata_mv.c +4 -34
@@ -4314,38 +4314,6 @@ static struct pci_driver mv_pci_driver = { }; -/* move to PCI layer or libata core? */ -static int pci_go_64 (struct pci_dev *pdev) -{ -int rc; - -if (!dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 ))) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); -if (rc) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev, -"64-bit DMA enable failed\n" ); -return rc; - } - } - }else { - rc =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev,"32-bit DMA enable failed\n" ); -return rc; - } - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev, -"32-bit consistent DMA enable failed\n" ); -return rc; - } - } - -return rc; -} -/** * mv_print_info - Dump key info to kernel log for perusal. * @host: ATA host to print info about
@@ -4430,9 +4398,11 @@ static int mv_pci_init_one(struct pci_dev *pdev, host->iomap =pcim_iomap_table (pdev); hpriv->base = host->iomap[MV_PRIMARY_BAR ]; - rc =pci_go_64 (pdev); -if (rc) + rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 )); +if (rc) { +dev_err (&pdev->dev,"DMA enable failed\n" );return rc; + } rc =mv_create_dma_pools (hpriv, &pdev->dev);if (rc)
Signature · 1 line
2.20.1
PATCH 5/8 sata_nv: use dma_set_mask_and_coherent
In reply to Christoph HellwigUse the dma_set_mask_and_coherent helper to set the DMA mask. Rely on the relatively recent change that setting a larger than required mask will never fail to avoid the need for the boilerplate 32-bit fallback code.
--- drivers/ata/sata_nv.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/ata/sata_nv.c +3 -7
@@ -1122,14 +1122,10 @@ static int nv_adma_port_start(struct ata_port *ap)/* * Now that the legacy PRD and padding buffer are allocated we can -* try to raise the DMA mask to allocate the CPB/APRD table. +* raise the DMA mask to allocate the CPB/APRD table. */ - rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 )); -if (rc) { - rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) -return rc; - } +dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 )); + pp->adma_dma_mask = *dev->dma_mask; mem = dmam_alloc_coherent(dev, NV_ADMA_PORT_PRIV_DMA_SZ,
Signature · 1 line
2.20.1
PATCH 6/8 sata_qstor: use dma_set_mask_and_coherent
In reply to Christoph HellwigUse the dma_set_mask_and_coherent helper to set the DMA mask. Rely on the relatively recent change that setting a larger than required mask will never fail to avoid the need for the boilerplate 32-bit fallback code.
--- drivers/ata/sata_qstor.c | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-)
drivers/ata/sata_qstor.c +7 -27
@@ -538,33 +538,13 @@ static void qs_host_init(struct ata_host *host, unsigned int chip_id)static int qs_set_dma_masks (struct pci_dev *pdev,void __iomem *mmio_base) {u32 bus_info =readl (mmio_base +QS_HID_HPHY ); -int rc, have_64bit_bus = (bus_info &QS_HPHY_64BIT ); - -if (have_64bit_bus && - !dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 ))) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); -if (rc) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev, -"64-bit DMA enable failed\n" ); -return rc; - } - } - }else { - rc =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev,"32-bit DMA enable failed\n" ); -return rc; - } - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev, -"32-bit consistent DMA enable failed\n" ); -return rc; - } - } -return 0 ; +int dma_bits = (bus_info &QS_HPHY_64BIT ) ?64 :32 ; +int rc; + + rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (dma_bits)); +if (rc) +dev_err (&pdev->dev,"%d-bit DMA enable failed\n" , dma_bits); +return rc; } static int qs_ata_init_one(struct pci_dev *pdev,
Signature · 1 line
2.20.1
PATCH 7/8 sata_sil24: use dma_set_mask_and_coherent
In reply to Christoph HellwigUse the dma_set_mask_and_coherent helper to set the DMA mask. Rely on the relatively recent change that setting a larger than required mask will never fail to avoid the need for the boilerplate 32-bit fallback code.
--- drivers/ata/sata_sil24.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-)
drivers/ata/sata_sil24.c +4 -22
@@ -1302,28 +1302,10 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) host->iomap = iomap;/* configure and activate the device */ -if (!dma_set_mask (&pdev->dev,DMA_BIT_MASK (64 ))) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (64 )); -if (rc) { - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev, -"64-bit DMA enable failed\n" ); -return rc; - } - } - }else { - rc =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev,"32-bit DMA enable failed\n" ); -return rc; - } - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev, -"32-bit consistent DMA enable failed\n" ); -return rc; - } + rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 )); +if (rc) { +dev_err (&pdev->dev,"DMA enable failed\n" ); +return rc; }/* Set max read request size to 4096. This slightly increases
Signature · 1 line
2.20.1
PATCH 8/8 libata: switch remaining drivers to use dma_set_mask_and_coherent
In reply to Christoph HellwigUse dma_set_mask_and_coherent instead of separate dma_set_mask and dma_set_coherent_mask calls.
--- drivers/ata/libata-sff.c | 8 +------- drivers/ata/pata_atp867x.c | 7 +------ drivers/ata/pata_cs5520.c | 6 +----- drivers/ata/pata_hpt3x3.c | 5 +---- drivers/ata/pata_ninja32.c | 5 +---- drivers/ata/pata_pdc2027x.c | 6 +----- drivers/ata/pata_sil680.c | 5 +---- drivers/ata/sata_inic162x.c | 8 +------- drivers/ata/sata_promise.c | 5 +---- drivers/ata/sata_sil.c | 5 +---- drivers/ata/sata_svw.c | 5 +---- drivers/ata/sata_sx4.c | 5 +---- drivers/ata/sata_via.c | 9 +-------- drivers/ata/sata_vsc.c | 5 +---- 14 files changed, 14 insertions(+), 70 deletions(-)
drivers/ata/libata-sff.c +1 -7
@@ -3147,15 +3147,9 @@ void ata_pci_bmdma_init(struct ata_host *host)* ->sff_irq_clear method. Try to initialize bmdma_addr * regardless of dma masks. */ - rc =dma_set_mask (&pdev->dev,ATA_DMA_MASK ); + rc =dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK );if (rc)ata_bmdma_nodma (host,"failed to set dma mask" ); -if (!rc) { - rc =dma_set_coherent_mask (&pdev->dev,ATA_DMA_MASK ); -if (rc) -ata_bmdma_nodma (host, -"failed to set consistent dma mask" ); - }/* request and iomap DMA region */ rc =pcim_iomap_regions (pdev,1 <<4 ,dev_driver_string (gdev));
drivers/ata/pata_atp867x.c +1 -6
@@ -463,12 +463,7 @@ static int atp867x_ata_pci_sff_init_host(struct ata_host *host)atp867x_fixup (host); - rc =dma_set_mask (&pdev->dev,ATA_DMA_MASK ); -if (rc) -return rc; - - rc =dma_set_coherent_mask (&pdev->dev,ATA_DMA_MASK ); -return rc; +return dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK ); } static int atp867x_init_one(struct pci_dev *pdev,
drivers/ata/pata_cs5520.c +1 -5
@@ -155,14 +155,10 @@ static int cs5520_init_one(struct pci_dev *pdev, const struct pci_device_id *id)return -ENODEV ; } -if (dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 ))) { +if (dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ))) { printk(KERN_ERR DRV_NAME ": unable to configure DMA mask.\n");return -ENODEV ; } -if (dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 ))) { - printk(KERN_ERR DRV_NAME ": unable to configure consistent DMA mask.\n"); -return -ENODEV ; - }/* Map IO ports and initialize host accordingly */ iomap[0 ] =devm_ioport_map (&pdev->dev, cmd_port[0 ],8 );
drivers/ata/pata_hpt3x3.c +1 -4
@@ -221,10 +221,7 @@ static int hpt3x3_init_one(struct pci_dev *pdev, const struct pci_device_id *id)if (rc)return rc; host->iomap =pcim_iomap_table (pdev); - rc =dma_set_mask (&pdev->dev,ATA_DMA_MASK ); -if (rc) -return rc; - rc =dma_set_coherent_mask (&pdev->dev,ATA_DMA_MASK ); + rc =dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK );if (rc)return rc;
drivers/ata/pata_ninja32.c +1 -4
@@ -123,10 +123,7 @@ static int ninja32_init_one(struct pci_dev *dev, const struct pci_device_id *id)return rc; host->iomap =pcim_iomap_table (dev); - rc =dma_set_mask (&dev->dev,ATA_DMA_MASK ); -if (rc) -return rc; - rc =dma_set_coherent_mask (&dev->dev,ATA_DMA_MASK ); + rc =dma_set_mask_and_coherent (&dev->dev,ATA_DMA_MASK );if (rc)return rc;pci_set_master (dev);
drivers/ata/pata_pdc2027x.c +1 -5
@@ -722,11 +722,7 @@ static int pdc2027x_init_one(struct pci_dev *pdev,return rc; host->iomap =pcim_iomap_table (pdev); - rc =dma_set_mask (&pdev->dev,ATA_DMA_MASK ); -if (rc) -return rc; - - rc =dma_set_coherent_mask (&pdev->dev,ATA_DMA_MASK ); + rc =dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK );if (rc)return rc;
drivers/ata/pata_sil680.c +1 -4
@@ -374,10 +374,7 @@ static int sil680_init_one(struct pci_dev *pdev, const struct pci_device_id *id) host->iomap =pcim_iomap_table (pdev);/* Setup DMA masks */ - rc =dma_set_mask (&pdev->dev,ATA_DMA_MASK ); -if (rc) -return rc; - rc =dma_set_coherent_mask (&pdev->dev,ATA_DMA_MASK ); + rc =dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK );if (rc)return rc;pci_set_master (pdev);
drivers/ata/sata_inic162x.c +1 -7
@@ -862,18 +862,12 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) }/* Set dma_mask. This devices doesn't support 64bit addressing. */ - rc =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); + rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (rc) {dev_err (&pdev->dev,"32-bit DMA enable failed\n" );return rc; } - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) { -dev_err (&pdev->dev,"32-bit consistent DMA enable failed\n" ); -return rc; - } - rc =init_controller (hpriv->mmio_base, hpriv->cached_hctl);if (rc) {dev_err (&pdev->dev,"failed to initialize controller\n" );
drivers/ata/sata_promise.c +1 -4
@@ -1230,10 +1230,7 @@ static int pdc_ata_init_one(struct pci_dev *pdev,/* initialize adapter */ pdc_host_init (host); - rc =dma_set_mask (&pdev->dev,ATA_DMA_MASK ); -if (rc) -return rc; - rc =dma_set_coherent_mask (&pdev->dev,ATA_DMA_MASK ); + rc =dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK );if (rc)return rc;
drivers/ata/sata_sil.c +1 -4
@@ -757,10 +757,7 @@ static int sil_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)return rc; host->iomap =pcim_iomap_table (pdev); - rc =dma_set_mask (&pdev->dev,ATA_DMA_MASK ); -if (rc) -return rc; - rc =dma_set_coherent_mask (&pdev->dev,ATA_DMA_MASK ); + rc =dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK );if (rc)return rc;
drivers/ata/sata_svw.c +1 -4
@@ -471,10 +471,7 @@ static int k2_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *enata_port_pbar_desc (ap,5 , offset,"port" ); } - rc =dma_set_mask (&pdev->dev,ATA_DMA_MASK ); -if (rc) -return rc; - rc =dma_set_coherent_mask (&pdev->dev,ATA_DMA_MASK ); + rc =dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK );if (rc)return rc;
drivers/ata/sata_sx4.c +1 -4
@@ -1470,10 +1470,7 @@ static int pdc_sata_init_one(struct pci_dev *pdev, }/* configure and activate */ - rc =dma_set_mask (&pdev->dev,ATA_DMA_MASK ); -if (rc) -return rc; - rc =dma_set_coherent_mask (&pdev->dev,ATA_DMA_MASK ); + rc =dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK );if (rc)return rc;
drivers/ata/sata_via.c +1 -8
@@ -505,14 +505,7 @@ static int vt6421_prepare_host(struct pci_dev *pdev, struct ata_host **r_host)for (i =0 ; i < host->n_ports; i++)vt6421_init_addrs (host->ports[i]); - rc =dma_set_mask (&pdev->dev,ATA_DMA_MASK ); -if (rc) -return rc; - rc =dma_set_coherent_mask (&pdev->dev,ATA_DMA_MASK ); -if (rc) -return rc; - -return 0 ; +return dma_set_mask_and_coherent (&pdev->dev,ATA_DMA_MASK ); }static int vt8251_prepare_host (struct pci_dev *pdev,struct ata_host **r_host)
drivers/ata/sata_vsc.c +1 -4
@@ -371,10 +371,7 @@ static int vsc_sata_init_one(struct pci_dev *pdev,/* * Use 32 bit DMA mask, because 64 bit address support is poor. */ - rc =dma_set_mask (&pdev->dev,DMA_BIT_MASK (32 )); -if (rc) -return rc; - rc =dma_set_coherent_mask (&pdev->dev,DMA_BIT_MASK (32 )); + rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (rc)return rc;
Signature · 1 line
2.20.1