[PATCH 27/28] ips: switch to generic DMA API
Switch from the legacy PCI DMA API to the generic DMA API. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- drivers/scsi/ips.c | 80 -- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index bd6ac6b5980a..378b6f37b613 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -208,7 +208,7 @@ module_param(ips, charp, 0); #define IPS_DMA_DIR(scb) ((!scb->scsi_cmd || ips_is_passthru(scb->scsi_cmd) || \ DMA_NONE == scb->scsi_cmd->sc_data_direction) ? \ - PCI_DMA_BIDIRECTIONAL : \ + DMA_BIDIRECTIONAL : \ scb->scsi_cmd->sc_data_direction) #ifdef IPS_DEBUG @@ -1529,11 +1529,12 @@ ips_alloc_passthru_buffer(ips_ha_t * ha, int length) if (ha->ioctl_data && length <= ha->ioctl_len) return 0; /* there is no buffer or it's not big enough, allocate a new one */ - bigger_buf = pci_alloc_consistent(ha->pcidev, length, _busaddr); + bigger_buf = dma_alloc_coherent(>pcidev->dev, length, _busaddr, + GFP_KERNEL); if (bigger_buf) { /* free the old memory */ - pci_free_consistent(ha->pcidev, ha->ioctl_len, ha->ioctl_data, - ha->ioctl_busaddr); + dma_free_coherent(>pcidev->dev, ha->ioctl_len, + ha->ioctl_data, ha->ioctl_busaddr); /* use the new memory */ ha->ioctl_data = (char *) bigger_buf; ha->ioctl_len = length; @@ -1678,9 +1679,8 @@ ips_flash_copperhead(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb) } else if (!ha->flash_data) { datasize = pt->CoppCP.cmd.flashfw.total_packets * pt->CoppCP.cmd.flashfw.count; - ha->flash_data = pci_alloc_consistent(ha->pcidev, - datasize, - >flash_busaddr); + ha->flash_data = dma_alloc_coherent(>pcidev->dev, + datasize, >flash_busaddr, GFP_KERNEL); if (!ha->flash_data){ printk(KERN_WARNING "Unable to allocate a flash buffer\n"); return IPS_FAILURE; @@ -1858,7 +1858,7 @@ ips_flash_firmware(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb) scb->data_len = ha->flash_datasize; scb->data_busaddr = - pci_map_single(ha->pcidev, ha->flash_data, scb->data_len, + dma_map_single(>pcidev->dev, ha->flash_data, scb->data_len, IPS_DMA_DIR(scb)); scb->flags |= IPS_SCB_MAP_SINGLE; scb->cmd.flashfw.command_id = IPS_COMMAND_ID(ha, scb); @@ -1880,8 +1880,8 @@ ips_free_flash_copperhead(ips_ha_t * ha) if (ha->flash_data == ips_FlashData) test_and_clear_bit(0, _FlashDataInUse); else if (ha->flash_data) - pci_free_consistent(ha->pcidev, ha->flash_len, ha->flash_data, - ha->flash_busaddr); + dma_free_coherent(>pcidev->dev, ha->flash_len, + ha->flash_data, ha->flash_busaddr); ha->flash_data = NULL; } @@ -4212,7 +4212,7 @@ ips_free(ips_ha_t * ha) if (ha) { if (ha->enq) { - pci_free_consistent(ha->pcidev, sizeof(IPS_ENQ), + dma_free_coherent(>pcidev->dev, sizeof(IPS_ENQ), ha->enq, ha->enq_busaddr); ha->enq = NULL; } @@ -4221,7 +4221,7 @@ ips_free(ips_ha_t * ha) ha->conf = NULL; if (ha->adapt) { - pci_free_consistent(ha->pcidev, + dma_free_coherent(>pcidev->dev, sizeof (IPS_ADAPTER) + sizeof (IPS_IO_CMD), ha->adapt, ha->adapt->hw_status_start); @@ -4229,7 +4229,7 @@ ips_free(ips_ha_t * ha) } if (ha->logical_drive_info) { - pci_free_consistent(ha->pcidev, + dma_free_coherent(>pcidev->dev, sizeof (IPS_LD_INFO), ha->logical_drive_info, ha->logical_drive_info_dma_addr); @@ -4243,7 +4243,7 @@ ips_free(ips_ha_t * ha) ha->subsys = NULL; if (ha->ioctl_data) { - pci_free_consistent(ha->pcidev, ha->ioctl_len, + dma_free_coherent(>pcidev->dev, ha->ioctl_len,
Re: [PATCH 27/28] ips: switch to generic DMA API
Looks good, Reviewed-by: Johannes Thumshirn -- Johannes ThumshirnSUSE Labs jthumsh...@suse.de+49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
[PATCH 27/28] ips: switch to generic DMA API
Switch from the legacy PCI DMA API to the generic DMA API. Signed-off-by: Christoph Hellwig --- drivers/scsi/ips.c | 80 -- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index bd6ac6b5980a..378b6f37b613 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c @@ -208,7 +208,7 @@ module_param(ips, charp, 0); #define IPS_DMA_DIR(scb) ((!scb->scsi_cmd || ips_is_passthru(scb->scsi_cmd) || \ DMA_NONE == scb->scsi_cmd->sc_data_direction) ? \ - PCI_DMA_BIDIRECTIONAL : \ + DMA_BIDIRECTIONAL : \ scb->scsi_cmd->sc_data_direction) #ifdef IPS_DEBUG @@ -1529,11 +1529,12 @@ ips_alloc_passthru_buffer(ips_ha_t * ha, int length) if (ha->ioctl_data && length <= ha->ioctl_len) return 0; /* there is no buffer or it's not big enough, allocate a new one */ - bigger_buf = pci_alloc_consistent(ha->pcidev, length, _busaddr); + bigger_buf = dma_alloc_coherent(>pcidev->dev, length, _busaddr, + GFP_KERNEL); if (bigger_buf) { /* free the old memory */ - pci_free_consistent(ha->pcidev, ha->ioctl_len, ha->ioctl_data, - ha->ioctl_busaddr); + dma_free_coherent(>pcidev->dev, ha->ioctl_len, + ha->ioctl_data, ha->ioctl_busaddr); /* use the new memory */ ha->ioctl_data = (char *) bigger_buf; ha->ioctl_len = length; @@ -1678,9 +1679,8 @@ ips_flash_copperhead(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb) } else if (!ha->flash_data) { datasize = pt->CoppCP.cmd.flashfw.total_packets * pt->CoppCP.cmd.flashfw.count; - ha->flash_data = pci_alloc_consistent(ha->pcidev, - datasize, - >flash_busaddr); + ha->flash_data = dma_alloc_coherent(>pcidev->dev, + datasize, >flash_busaddr, GFP_KERNEL); if (!ha->flash_data){ printk(KERN_WARNING "Unable to allocate a flash buffer\n"); return IPS_FAILURE; @@ -1858,7 +1858,7 @@ ips_flash_firmware(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb) scb->data_len = ha->flash_datasize; scb->data_busaddr = - pci_map_single(ha->pcidev, ha->flash_data, scb->data_len, + dma_map_single(>pcidev->dev, ha->flash_data, scb->data_len, IPS_DMA_DIR(scb)); scb->flags |= IPS_SCB_MAP_SINGLE; scb->cmd.flashfw.command_id = IPS_COMMAND_ID(ha, scb); @@ -1880,8 +1880,8 @@ ips_free_flash_copperhead(ips_ha_t * ha) if (ha->flash_data == ips_FlashData) test_and_clear_bit(0, _FlashDataInUse); else if (ha->flash_data) - pci_free_consistent(ha->pcidev, ha->flash_len, ha->flash_data, - ha->flash_busaddr); + dma_free_coherent(>pcidev->dev, ha->flash_len, + ha->flash_data, ha->flash_busaddr); ha->flash_data = NULL; } @@ -4212,7 +4212,7 @@ ips_free(ips_ha_t * ha) if (ha) { if (ha->enq) { - pci_free_consistent(ha->pcidev, sizeof(IPS_ENQ), + dma_free_coherent(>pcidev->dev, sizeof(IPS_ENQ), ha->enq, ha->enq_busaddr); ha->enq = NULL; } @@ -4221,7 +4221,7 @@ ips_free(ips_ha_t * ha) ha->conf = NULL; if (ha->adapt) { - pci_free_consistent(ha->pcidev, + dma_free_coherent(>pcidev->dev, sizeof (IPS_ADAPTER) + sizeof (IPS_IO_CMD), ha->adapt, ha->adapt->hw_status_start); @@ -4229,7 +4229,7 @@ ips_free(ips_ha_t * ha) } if (ha->logical_drive_info) { - pci_free_consistent(ha->pcidev, + dma_free_coherent(>pcidev->dev, sizeof (IPS_LD_INFO), ha->logical_drive_info, ha->logical_drive_info_dma_addr); @@ -4243,7 +4243,7 @@ ips_free(ips_ha_t * ha) ha->subsys = NULL; if (ha->ioctl_data) { - pci_free_consistent(ha->pcidev, ha->ioctl_len, + dma_free_coherent(>pcidev->dev, ha->ioctl_len,