Skip to content

Commit 32e7696

Browse files
Christoph Hellwigmartinkpetersen
authored andcommitted
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>
1 parent 6917a9c commit 32e7696

File tree

1 file changed

+41
-39
lines changed

1 file changed

+41
-39
lines changed

drivers/scsi/ips.c

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ module_param(ips, charp, 0);
208208

209209
#define IPS_DMA_DIR(scb) ((!scb->scsi_cmd || ips_is_passthru(scb->scsi_cmd) || \
210210
DMA_NONE == scb->scsi_cmd->sc_data_direction) ? \
211-
PCI_DMA_BIDIRECTIONAL : \
211+
DMA_BIDIRECTIONAL : \
212212
scb->scsi_cmd->sc_data_direction)
213213

214214
#ifdef IPS_DEBUG
@@ -1529,11 +1529,12 @@ ips_alloc_passthru_buffer(ips_ha_t * ha, int length)
15291529
if (ha->ioctl_data && length <= ha->ioctl_len)
15301530
return 0;
15311531
/* 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);
15331534
if (bigger_buf) {
15341535
/* free the old memory */
1535-
pci_free_consistent(ha->pcidev, ha->ioctl_len, ha->ioctl_data,
1536-
ha->ioctl_busaddr);
1536+
dma_free_coherent(&ha->pcidev->dev, ha->ioctl_len,
1537+
ha->ioctl_data, ha->ioctl_busaddr);
15371538
/* use the new memory */
15381539
ha->ioctl_data = (char *) bigger_buf;
15391540
ha->ioctl_len = length;
@@ -1678,9 +1679,8 @@ ips_flash_copperhead(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb)
16781679
} else if (!ha->flash_data) {
16791680
datasize = pt->CoppCP.cmd.flashfw.total_packets *
16801681
pt->CoppCP.cmd.flashfw.count;
1681-
ha->flash_data = pci_alloc_consistent(ha->pcidev,
1682-
datasize,
1683-
&ha->flash_busaddr);
1682+
ha->flash_data = dma_alloc_coherent(&ha->pcidev->dev,
1683+
datasize, &ha->flash_busaddr, GFP_KERNEL);
16841684
if (!ha->flash_data){
16851685
printk(KERN_WARNING "Unable to allocate a flash buffer\n");
16861686
return IPS_FAILURE;
@@ -1858,7 +1858,7 @@ ips_flash_firmware(ips_ha_t * ha, ips_passthru_t * pt, ips_scb_t * scb)
18581858

18591859
scb->data_len = ha->flash_datasize;
18601860
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,
18621862
IPS_DMA_DIR(scb));
18631863
scb->flags |= IPS_SCB_MAP_SINGLE;
18641864
scb->cmd.flashfw.command_id = IPS_COMMAND_ID(ha, scb);
@@ -1880,8 +1880,8 @@ ips_free_flash_copperhead(ips_ha_t * ha)
18801880
if (ha->flash_data == ips_FlashData)
18811881
test_and_clear_bit(0, &ips_FlashDataInUse);
18821882
else if (ha->flash_data)
1883-
pci_free_consistent(ha->pcidev, ha->flash_len, ha->flash_data,
1884-
ha->flash_busaddr);
1883+
dma_free_coherent(&ha->pcidev->dev, ha->flash_len,
1884+
ha->flash_data, ha->flash_busaddr);
18851885
ha->flash_data = NULL;
18861886
}
18871887

@@ -4213,7 +4213,7 @@ ips_free(ips_ha_t * ha)
42134213

42144214
if (ha) {
42154215
if (ha->enq) {
4216-
pci_free_consistent(ha->pcidev, sizeof(IPS_ENQ),
4216+
dma_free_coherent(&ha->pcidev->dev, sizeof(IPS_ENQ),
42174217
ha->enq, ha->enq_busaddr);
42184218
ha->enq = NULL;
42194219
}
@@ -4222,15 +4222,15 @@ ips_free(ips_ha_t * ha)
42224222
ha->conf = NULL;
42234223

42244224
if (ha->adapt) {
4225-
pci_free_consistent(ha->pcidev,
4225+
dma_free_coherent(&ha->pcidev->dev,
42264226
sizeof (IPS_ADAPTER) +
42274227
sizeof (IPS_IO_CMD), ha->adapt,
42284228
ha->adapt->hw_status_start);
42294229
ha->adapt = NULL;
42304230
}
42314231

42324232
if (ha->logical_drive_info) {
4233-
pci_free_consistent(ha->pcidev,
4233+
dma_free_coherent(&ha->pcidev->dev,
42344234
sizeof (IPS_LD_INFO),
42354235
ha->logical_drive_info,
42364236
ha->logical_drive_info_dma_addr);
@@ -4244,7 +4244,7 @@ ips_free(ips_ha_t * ha)
42444244
ha->subsys = NULL;
42454245

42464246
if (ha->ioctl_data) {
4247-
pci_free_consistent(ha->pcidev, ha->ioctl_len,
4247+
dma_free_coherent(&ha->pcidev->dev, ha->ioctl_len,
42484248
ha->ioctl_data, ha->ioctl_busaddr);
42494249
ha->ioctl_data = NULL;
42504250
ha->ioctl_datasize = 0;
@@ -4277,11 +4277,11 @@ static int
42774277
ips_deallocatescbs(ips_ha_t * ha, int cmds)
42784278
{
42794279
if (ha->scbs) {
4280-
pci_free_consistent(ha->pcidev,
4280+
dma_free_coherent(&ha->pcidev->dev,
42814281
IPS_SGLIST_SIZE(ha) * IPS_MAX_SG * cmds,
42824282
ha->scbs->sg_list.list,
42834283
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,
42854285
ha->scbs, ha->scbs->scb_busaddr);
42864286
ha->scbs = NULL;
42874287
} /* end if */
@@ -4308,17 +4308,16 @@ ips_allocatescbs(ips_ha_t * ha)
43084308
METHOD_TRACE("ips_allocatescbs", 1);
43094309

43104310
/* Allocate memory for the SCBs */
4311-
ha->scbs =
4312-
pci_alloc_consistent(ha->pcidev, ha->max_cmds * sizeof (ips_scb_t),
4313-
&command_dma);
4311+
ha->scbs = dma_alloc_coherent(&ha->pcidev->dev,
4312+
ha->max_cmds * sizeof (ips_scb_t),
4313+
&command_dma, GFP_KERNEL);
43144314
if (ha->scbs == NULL)
43154315
return 0;
4316-
ips_sg.list =
4317-
pci_alloc_consistent(ha->pcidev,
4318-
IPS_SGLIST_SIZE(ha) * IPS_MAX_SG *
4319-
ha->max_cmds, &sg_dma);
4316+
ips_sg.list = dma_alloc_coherent(&ha->pcidev->dev,
4317+
IPS_SGLIST_SIZE(ha) * IPS_MAX_SG * ha->max_cmds,
4318+
&sg_dma, GFP_KERNEL);
43204319
if (ips_sg.list == NULL) {
4321-
pci_free_consistent(ha->pcidev,
4320+
dma_free_coherent(&ha->pcidev->dev,
43224321
ha->max_cmds * sizeof (ips_scb_t), ha->scbs,
43234322
command_dma);
43244323
return 0;
@@ -4447,8 +4446,8 @@ ips_freescb(ips_ha_t * ha, ips_scb_t * scb)
44474446
if (scb->flags & IPS_SCB_MAP_SG)
44484447
scsi_dma_unmap(scb->scsi_cmd);
44494448
else if (scb->flags & IPS_SCB_MAP_SINGLE)
4450-
pci_unmap_single(ha->pcidev, scb->data_busaddr, scb->data_len,
4451-
IPS_DMA_DIR(scb));
4449+
dma_unmap_single(&ha->pcidev->dev, scb->data_busaddr,
4450+
scb->data_len, IPS_DMA_DIR(scb));
44524451

44534452
/* check to make sure this is not our "special" scb */
44544453
if (IPS_COMMAND_ID(ha, scb) < (ha->max_cmds - 1)) {
@@ -4560,7 +4559,8 @@ ips_flush_and_reset(ips_ha_t *ha)
45604559
dma_addr_t command_dma;
45614560

45624561
/* 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);
45644564
if (scb) {
45654565
memset(scb, 0, sizeof(ips_scb_t));
45664566
ips_init_scb(ha, scb);
@@ -4595,7 +4595,7 @@ ips_flush_and_reset(ips_ha_t *ha)
45954595
/* Now RESET and INIT the adapter */
45964596
(*ha->func.reset) (ha);
45974597

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);
45994599
return;
46004600
}
46014601

@@ -6927,29 +6927,30 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr)
69276927
* are guaranteed to be < 4G.
69286928
*/
69296929
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))) {
69316931
(ha)->flags |= IPS_HA_ENH_SG;
69326932
} 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) {
69346934
printk(KERN_WARNING "Unable to set DMA Mask\n");
69356935
return ips_abort_init(ha, index);
69366936
}
69376937
}
69386938
if(ips_cd_boot && !ips_FlashData){
6939-
ips_FlashData = pci_alloc_consistent(pci_dev, PAGE_SIZE << 7,
6940-
&ips_flashbusaddr);
6939+
ips_FlashData = dma_alloc_coherent(&pci_dev->dev,
6940+
PAGE_SIZE << 7, &ips_flashbusaddr, GFP_KERNEL);
69416941
}
69426942

6943-
ha->enq = pci_alloc_consistent(pci_dev, sizeof (IPS_ENQ),
6944-
&ha->enq_busaddr);
6943+
ha->enq = dma_alloc_coherent(&pci_dev->dev, sizeof (IPS_ENQ),
6944+
&ha->enq_busaddr, GFP_KERNEL);
69456945
if (!ha->enq) {
69466946
IPS_PRINTK(KERN_WARNING, pci_dev,
69476947
"Unable to allocate host inquiry structure\n");
69486948
return ips_abort_init(ha, index);
69496949
}
69506950

6951-
ha->adapt = pci_alloc_consistent(pci_dev, sizeof (IPS_ADAPTER) +
6952-
sizeof (IPS_IO_CMD), &dma_address);
6951+
ha->adapt = dma_alloc_coherent(&pci_dev->dev,
6952+
sizeof (IPS_ADAPTER) + sizeof (IPS_IO_CMD),
6953+
&dma_address, GFP_KERNEL);
69536954
if (!ha->adapt) {
69546955
IPS_PRINTK(KERN_WARNING, pci_dev,
69556956
"Unable to allocate host adapt & dummy structures\n");
@@ -6960,7 +6961,8 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr)
69606961

69616962

69626963

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);
69646966
if (!ha->logical_drive_info) {
69656967
IPS_PRINTK(KERN_WARNING, pci_dev,
69666968
"Unable to allocate logical drive info structure\n");
@@ -6998,8 +7000,8 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr)
69987000
if (ips_ioctlsize < PAGE_SIZE)
69997001
ips_ioctlsize = PAGE_SIZE;
70007002

7001-
ha->ioctl_data = pci_alloc_consistent(pci_dev, ips_ioctlsize,
7002-
&ha->ioctl_busaddr);
7003+
ha->ioctl_data = dma_alloc_coherent(&pci_dev->dev, ips_ioctlsize,
7004+
&ha->ioctl_busaddr, GFP_KERNEL);
70037005
ha->ioctl_len = ips_ioctlsize;
70047006
if (!ha->ioctl_data) {
70057007
IPS_PRINTK(KERN_WARNING, pci_dev,

0 commit comments

Comments
 (0)