aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-10-11 04:15:35 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2018-10-17 21:58:53 -0400
commit32e76961dd63ebb2882f8a478889cc7f42fbfb4c (patch)
tree99cab9152dfaf8467fe7de15a58285c481ab2d43
parent6917a9cc28181b37d142f1c5813a6888f41572e7 (diff)
scsi: ips: switch to generic DMA API
Switch from the legacy PCI DMA API to the generic DMA API. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/ips.c80
1 files changed, 41 insertions, 39 deletions
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index fe587ef1741d..ee8a1ecd58fd 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -208,7 +208,7 @@ module_param(ips, charp, 0);
208 208
209#define IPS_DMA_DIR(scb) ((!scb->scsi_cmd || ips_is_passthru(scb->scsi_cmd) || \ 209#define IPS_DMA_DIR(scb) ((!scb->scsi_cmd || ips_is_passthru(scb->scsi_cmd) || \
210 DMA_NONE == scb->scsi_cmd->sc_data_direction) ? \ 210 DMA_NONE == scb->scsi_cmd->sc_data_direction) ? \
211 PCI_DMA_BIDIRECTIONAL : \ 211 DMA_BIDIRECTIONAL : \
212 scb->scsi_cmd->sc_data_direction) 212 scb->scsi_cmd->sc_data_direction)
213 213
214#ifdef IPS_DEBUG 214#ifdef IPS_DEBUG
@@ -1529,11 +1529,12 @@ ips_alloc_passthru_buffer(ips_ha_t * ha, int length)
1529 if (ha->ioctl_data && length <= ha->ioctl_len) 1529 if (ha->ioctl_data && length <= ha->ioctl_len)
1530 return 0; 1530 return 0;
1531 /* there is no buffer or it's not big enough, allocate a new one */ 1531 /* there is no buffer or it's not big enough, allocate a new one */
1532 bigger_buf = pci_alloc_consistent(ha->pcidev, length, &dma_busaddr); 1532 bigger_buf = dma_alloc_coherent(&ha->pcidev->dev, length, &dma_busaddr,
1533 GFP_KERNEL);
1533 if (bigger_buf) { 1534 if (bigger_buf) {
1534 /* free the old memory */ 1535 /* free the old memory */
1535 pci_free_consistent(ha->pcidev, ha->ioctl_len, ha->ioctl_data, 1536 dma_free_coherent(&ha->pcidev->dev, ha->ioctl_len,
1536 ha->ioctl_busaddr); 1537 ha->ioctl_data, ha->ioctl_busaddr);
1537 /* use the new memory */ 1538 /* use the new memory */
1538 ha->ioctl_data = (char *) bigger_buf; 1539 ha->ioctl_data = (char *) bigger_buf;
1539 ha->ioctl_len = length; 1540 ha->ioctl_len = length;
@@ -1678,9 +1679,8 @@ ips_flash_copperhead(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb)
1678 } else if (!ha->flash_data) { 1679 } else if (!ha->flash_data) {
1679 datasize = pt->CoppCP.cmd.flashfw.total_packets * 1680 datasize = pt->CoppCP.cmd.flashfw.total_packets *
1680 pt->CoppCP.cmd.flashfw.count; 1681 pt->CoppCP.cmd.flashfw.count;
1681 ha->flash_data = pci_alloc_consistent(ha->pcidev, 1682 ha->flash_data = dma_alloc_coherent(&ha->pcidev->dev,
1682 datasize, 1683 datasize, &ha->flash_busaddr, GFP_KERNEL);
1683 &ha->flash_busaddr);
1684 if (!ha->flash_data){ 1684 if (!ha->flash_data){
1685 printk(KERN_WARNING "Unable to allocate a flash buffer\n"); 1685 printk(KERN_WARNING "Unable to allocate a flash buffer\n");
1686 return IPS_FAILURE; 1686 return IPS_FAILURE;
@@ -1858,7 +1858,7 @@ ips_flash_firmware(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb)
1858 1858
1859 scb->data_len = ha->flash_datasize; 1859 scb->data_len = ha->flash_datasize;
1860 scb->data_busaddr = 1860 scb->data_busaddr =
1861 pci_map_single(ha->pcidev, ha->flash_data, scb->data_len, 1861 dma_map_single(&ha->pcidev->dev, ha->flash_data, scb->data_len,
1862 IPS_DMA_DIR(scb)); 1862 IPS_DMA_DIR(scb));
1863 scb->flags |= IPS_SCB_MAP_SINGLE; 1863 scb->flags |= IPS_SCB_MAP_SINGLE;
1864 scb->cmd.flashfw.command_id = IPS_COMMAND_ID(ha, scb); 1864 scb->cmd.flashfw.command_id = IPS_COMMAND_ID(ha, scb);
@@ -1880,8 +1880,8 @@ ips_free_flash_copperhead(ips_ha_t * ha)
1880 if (ha->flash_data == ips_FlashData) 1880 if (ha->flash_data == ips_FlashData)
1881 test_and_clear_bit(0, &ips_FlashDataInUse); 1881 test_and_clear_bit(0, &ips_FlashDataInUse);
1882 else if (ha->flash_data) 1882 else if (ha->flash_data)
1883 pci_free_consistent(ha->pcidev, ha->flash_len, ha->flash_data, 1883 dma_free_coherent(&ha->pcidev->dev, ha->flash_len,
1884 ha->flash_busaddr); 1884 ha->flash_data, ha->flash_busaddr);
1885 ha->flash_data = NULL; 1885 ha->flash_data = NULL;
1886} 1886}
1887 1887
@@ -4213,7 +4213,7 @@ ips_free(ips_ha_t * ha)
4213 4213
4214 if (ha) { 4214 if (ha) {
4215 if (ha->enq) { 4215 if (ha->enq) {
4216 pci_free_consistent(ha->pcidev, sizeof(IPS_ENQ), 4216 dma_free_coherent(&ha->pcidev->dev, sizeof(IPS_ENQ),
4217 ha->enq, ha->enq_busaddr); 4217 ha->enq, ha->enq_busaddr);
4218 ha->enq = NULL; 4218 ha->enq = NULL;
4219 } 4219 }
@@ -4222,7 +4222,7 @@ ips_free(ips_ha_t * ha)
4222 ha->conf = NULL; 4222 ha->conf = NULL;
4223 4223
4224 if (ha->adapt) { 4224 if (ha->adapt) {
4225 pci_free_consistent(ha->pcidev, 4225 dma_free_coherent(&ha->pcidev->dev,
4226 sizeof (IPS_ADAPTER) + 4226 sizeof (IPS_ADAPTER) +
4227 sizeof (IPS_IO_CMD), ha->adapt, 4227 sizeof (IPS_IO_CMD), ha->adapt,
4228 ha->adapt->hw_status_start); 4228 ha->adapt->hw_status_start);
@@ -4230,7 +4230,7 @@ ips_free(ips_ha_t * ha)
4230 } 4230 }
4231 4231
4232 if (ha->logical_drive_info) { 4232 if (ha->logical_drive_info) {
4233 pci_free_consistent(ha->pcidev, 4233 dma_free_coherent(&ha->pcidev->dev,
4234 sizeof (IPS_LD_INFO), 4234 sizeof (IPS_LD_INFO),
4235 ha->logical_drive_info, 4235 ha->logical_drive_info,
4236 ha->logical_drive_info_dma_addr); 4236 ha->logical_drive_info_dma_addr);
@@ -4244,7 +4244,7 @@ ips_free(ips_ha_t * ha)
4244 ha->subsys = NULL; 4244 ha->subsys = NULL;
4245 4245
4246 if (ha->ioctl_data) { 4246 if (ha->ioctl_data) {
4247 pci_free_consistent(ha->pcidev, ha->ioctl_len, 4247 dma_free_coherent(&ha->pcidev->dev, ha->ioctl_len,
4248 ha->ioctl_data, ha->ioctl_busaddr); 4248 ha->ioctl_data, ha->ioctl_busaddr);
4249 ha->ioctl_data = NULL; 4249 ha->ioctl_data = NULL;
4250 ha->ioctl_datasize = 0; 4250 ha->ioctl_datasize = 0;
@@ -4277,11 +4277,11 @@ static int
4277ips_deallocatescbs(ips_ha_t * ha, int cmds) 4277ips_deallocatescbs(ips_ha_t * ha, int cmds)
4278{ 4278{
4279 if (ha->scbs) { 4279 if (ha->scbs) {
4280 pci_free_consistent(ha->pcidev, 4280 dma_free_coherent(&ha->pcidev->dev,
4281 IPS_SGLIST_SIZE(ha) * IPS_MAX_SG * cmds, 4281 IPS_SGLIST_SIZE(ha) * IPS_MAX_SG * cmds,
4282 ha->scbs->sg_list.list, 4282 ha->scbs->sg_list.list,
4283 ha->scbs->sg_busaddr); 4283 ha->scbs->sg_busaddr);
4284 pci_free_consistent(ha->pcidev, sizeof (ips_scb_t) * cmds, 4284 dma_free_coherent(&ha->pcidev->dev, sizeof (ips_scb_t) * cmds,
4285 ha->scbs, ha->scbs->scb_busaddr); 4285 ha->scbs, ha->scbs->scb_busaddr);
4286 ha->scbs = NULL; 4286 ha->scbs = NULL;
4287 } /* end if */ 4287 } /* end if */
@@ -4308,17 +4308,16 @@ ips_allocatescbs(ips_ha_t * ha)
4308 METHOD_TRACE("ips_allocatescbs", 1); 4308 METHOD_TRACE("ips_allocatescbs", 1);
4309 4309
4310 /* Allocate memory for the SCBs */ 4310 /* Allocate memory for the SCBs */
4311 ha->scbs = 4311 ha->scbs = dma_alloc_coherent(&ha->pcidev->dev,
4312 pci_alloc_consistent(ha->pcidev, ha->max_cmds * sizeof (ips_scb_t), 4312 ha->max_cmds * sizeof (ips_scb_t),
4313 &command_dma); 4313 &command_dma, GFP_KERNEL);
4314 if (ha->scbs == NULL) 4314 if (ha->scbs == NULL)
4315 return 0; 4315 return 0;
4316 ips_sg.list = 4316 ips_sg.list = dma_alloc_coherent(&ha->pcidev->dev,
4317 pci_alloc_consistent(ha->pcidev, 4317 IPS_SGLIST_SIZE(ha) * IPS_MAX_SG * ha->max_cmds,
4318 IPS_SGLIST_SIZE(ha) * IPS_MAX_SG * 4318 &sg_dma, GFP_KERNEL);
4319 ha->max_cmds, &sg_dma);
4320 if (ips_sg.list == NULL) { 4319 if (ips_sg.list == NULL) {
4321 pci_free_consistent(ha->pcidev, 4320 dma_free_coherent(&ha->pcidev->dev,
4322 ha->max_cmds * sizeof (ips_scb_t), ha->scbs, 4321 ha->max_cmds * sizeof (ips_scb_t), ha->scbs,
4323 command_dma); 4322 command_dma);
4324 return 0; 4323 return 0;
@@ -4447,8 +4446,8 @@ ips_freescb(ips_ha_t * ha, ips_scb_t * scb)
4447 if (scb->flags & IPS_SCB_MAP_SG) 4446 if (scb->flags & IPS_SCB_MAP_SG)
4448 scsi_dma_unmap(scb->scsi_cmd); 4447 scsi_dma_unmap(scb->scsi_cmd);
4449 else if (scb->flags & IPS_SCB_MAP_SINGLE) 4448 else if (scb->flags & IPS_SCB_MAP_SINGLE)
4450 pci_unmap_single(ha->pcidev, scb->data_busaddr, scb->data_len, 4449 dma_unmap_single(&ha->pcidev->dev, scb->data_busaddr,
4451 IPS_DMA_DIR(scb)); 4450 scb->data_len, IPS_DMA_DIR(scb));
4452 4451
4453 /* check to make sure this is not our "special" scb */ 4452 /* check to make sure this is not our "special" scb */
4454 if (IPS_COMMAND_ID(ha, scb) < (ha->max_cmds - 1)) { 4453 if (IPS_COMMAND_ID(ha, scb) < (ha->max_cmds - 1)) {
@@ -4560,7 +4559,8 @@ ips_flush_and_reset(ips_ha_t *ha)
4560 dma_addr_t command_dma; 4559 dma_addr_t command_dma;
4561 4560
4562 /* Create a usuable SCB */ 4561 /* Create a usuable SCB */
4563 scb = pci_alloc_consistent(ha->pcidev, sizeof(ips_scb_t), &command_dma); 4562 scb = dma_alloc_coherent(&ha->pcidev->dev, sizeof(ips_scb_t),
4563 &command_dma, GFP_KERNEL);
4564 if (scb) { 4564 if (scb) {
4565 memset(scb, 0, sizeof(ips_scb_t)); 4565 memset(scb, 0, sizeof(ips_scb_t));
4566 ips_init_scb(ha, scb); 4566 ips_init_scb(ha, scb);
@@ -4595,7 +4595,7 @@ ips_flush_and_reset(ips_ha_t *ha)
4595 /* Now RESET and INIT the adapter */ 4595 /* Now RESET and INIT the adapter */
4596 (*ha->func.reset) (ha); 4596 (*ha->func.reset) (ha);
4597 4597
4598 pci_free_consistent(ha->pcidev, sizeof(ips_scb_t), scb, command_dma); 4598 dma_free_coherent(&ha->pcidev->dev, sizeof(ips_scb_t), scb, command_dma);
4599 return; 4599 return;
4600} 4600}
4601 4601
@@ -6927,29 +6927,30 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr)
6927 * are guaranteed to be < 4G. 6927 * are guaranteed to be < 4G.
6928 */ 6928 */
6929 if (IPS_ENABLE_DMA64 && IPS_HAS_ENH_SGLIST(ha) && 6929 if (IPS_ENABLE_DMA64 && IPS_HAS_ENH_SGLIST(ha) &&
6930 !pci_set_dma_mask(ha->pcidev, DMA_BIT_MASK(64))) { 6930 !dma_set_mask(&ha->pcidev->dev, DMA_BIT_MASK(64))) {
6931 (ha)->flags |= IPS_HA_ENH_SG; 6931 (ha)->flags |= IPS_HA_ENH_SG;
6932 } else { 6932 } else {
6933 if (pci_set_dma_mask(ha->pcidev, DMA_BIT_MASK(32)) != 0) { 6933 if (dma_set_mask(&ha->pcidev->dev, DMA_BIT_MASK(32)) != 0) {
6934 printk(KERN_WARNING "Unable to set DMA Mask\n"); 6934 printk(KERN_WARNING "Unable to set DMA Mask\n");
6935 return ips_abort_init(ha, index); 6935 return ips_abort_init(ha, index);
6936 } 6936 }
6937 } 6937 }
6938 if(ips_cd_boot && !ips_FlashData){ 6938 if(ips_cd_boot && !ips_FlashData){
6939 ips_FlashData = pci_alloc_consistent(pci_dev, PAGE_SIZE << 7, 6939 ips_FlashData = dma_alloc_coherent(&pci_dev->dev,
6940 &ips_flashbusaddr); 6940 PAGE_SIZE << 7, &ips_flashbusaddr, GFP_KERNEL);
6941 } 6941 }
6942 6942
6943 ha->enq = pci_alloc_consistent(pci_dev, sizeof (IPS_ENQ), 6943 ha->enq = dma_alloc_coherent(&pci_dev->dev, sizeof (IPS_ENQ),
6944 &ha->enq_busaddr); 6944 &ha->enq_busaddr, GFP_KERNEL);
6945 if (!ha->enq) { 6945 if (!ha->enq) {
6946 IPS_PRINTK(KERN_WARNING, pci_dev, 6946 IPS_PRINTK(KERN_WARNING, pci_dev,
6947 "Unable to allocate host inquiry structure\n"); 6947 "Unable to allocate host inquiry structure\n");
6948 return ips_abort_init(ha, index); 6948 return ips_abort_init(ha, index);
6949 } 6949 }
6950 6950
6951 ha->adapt = pci_alloc_consistent(pci_dev, sizeof (IPS_ADAPTER) + 6951 ha->adapt = dma_alloc_coherent(&pci_dev->dev,
6952 sizeof (IPS_IO_CMD), &dma_address); 6952 sizeof (IPS_ADAPTER) + sizeof (IPS_IO_CMD),
6953 &dma_address, GFP_KERNEL);
6953 if (!ha->adapt) { 6954 if (!ha->adapt) {
6954 IPS_PRINTK(KERN_WARNING, pci_dev, 6955 IPS_PRINTK(KERN_WARNING, pci_dev,
6955 "Unable to allocate host adapt & dummy structures\n"); 6956 "Unable to allocate host adapt & dummy structures\n");
@@ -6960,7 +6961,8 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr)
6960 6961
6961 6962
6962 6963
6963 ha->logical_drive_info = pci_alloc_consistent(pci_dev, sizeof (IPS_LD_INFO), &dma_address); 6964 ha->logical_drive_info = dma_alloc_coherent(&pci_dev->dev,
6965 sizeof (IPS_LD_INFO), &dma_address, GFP_KERNEL);
6964 if (!ha->logical_drive_info) { 6966 if (!ha->logical_drive_info) {
6965 IPS_PRINTK(KERN_WARNING, pci_dev, 6967 IPS_PRINTK(KERN_WARNING, pci_dev,
6966 "Unable to allocate logical drive info structure\n"); 6968 "Unable to allocate logical drive info structure\n");
@@ -6998,8 +7000,8 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr)
6998 if (ips_ioctlsize < PAGE_SIZE) 7000 if (ips_ioctlsize < PAGE_SIZE)
6999 ips_ioctlsize = PAGE_SIZE; 7001 ips_ioctlsize = PAGE_SIZE;
7000 7002
7001 ha->ioctl_data = pci_alloc_consistent(pci_dev, ips_ioctlsize, 7003 ha->ioctl_data = dma_alloc_coherent(&pci_dev->dev, ips_ioctlsize,
7002 &ha->ioctl_busaddr); 7004 &ha->ioctl_busaddr, GFP_KERNEL);
7003 ha->ioctl_len = ips_ioctlsize; 7005 ha->ioctl_len = ips_ioctlsize;
7004 if (!ha->ioctl_data) { 7006 if (!ha->ioctl_data) {
7005 IPS_PRINTK(KERN_WARNING, pci_dev, 7007 IPS_PRINTK(KERN_WARNING, pci_dev,