@@ -1041,14 +1041,15 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags,
1041
1041
* copying the data in this array into the correct place in the
1042
1042
* request and chain buffers.
1043
1043
*/
1044
- sglbuf = pci_alloc_consistent (ioc -> pcidev , MAX_SGL_BYTES , sglbuf_dma );
1044
+ sglbuf = dma_alloc_coherent (& ioc -> pcidev -> dev , MAX_SGL_BYTES ,
1045
+ sglbuf_dma , GFP_KERNEL );
1045
1046
if (sglbuf == NULL )
1046
1047
goto free_and_fail ;
1047
1048
1048
1049
if (sgdir & 0x04000000 )
1049
- dir = PCI_DMA_TODEVICE ;
1050
+ dir = DMA_TO_DEVICE ;
1050
1051
else
1051
- dir = PCI_DMA_FROMDEVICE ;
1052
+ dir = DMA_FROM_DEVICE ;
1052
1053
1053
1054
/* At start:
1054
1055
* sgl = sglbuf = point to beginning of sg buffer
@@ -1062,9 +1063,9 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags,
1062
1063
while (bytes_allocd < bytes ) {
1063
1064
this_alloc = min (alloc_sz , bytes - bytes_allocd );
1064
1065
buflist [buflist_ent ].len = this_alloc ;
1065
- buflist [buflist_ent ].kptr = pci_alloc_consistent ( ioc -> pcidev ,
1066
- this_alloc ,
1067
- & pa );
1066
+ buflist [buflist_ent ].kptr = dma_alloc_coherent ( & ioc -> pcidev -> dev ,
1067
+ this_alloc ,
1068
+ & pa , GFP_KERNEL );
1068
1069
if (buflist [buflist_ent ].kptr == NULL ) {
1069
1070
alloc_sz = alloc_sz / 2 ;
1070
1071
if (alloc_sz == 0 ) {
@@ -1080,8 +1081,9 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags,
1080
1081
1081
1082
bytes_allocd += this_alloc ;
1082
1083
sgl -> FlagsLength = (0x10000000 |sgdir |this_alloc );
1083
- dma_addr = pci_map_single (ioc -> pcidev ,
1084
- buflist [buflist_ent ].kptr , this_alloc , dir );
1084
+ dma_addr = dma_map_single (& ioc -> pcidev -> dev ,
1085
+ buflist [buflist_ent ].kptr ,
1086
+ this_alloc , dir );
1085
1087
sgl -> Address = dma_addr ;
1086
1088
1087
1089
fragcnt ++ ;
@@ -1140,9 +1142,11 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, int sge_offset, int *frags,
1140
1142
kptr = buflist [i ].kptr ;
1141
1143
len = buflist [i ].len ;
1142
1144
1143
- pci_free_consistent (ioc -> pcidev , len , kptr , dma_addr );
1145
+ dma_free_coherent (& ioc -> pcidev -> dev , len , kptr ,
1146
+ dma_addr );
1144
1147
}
1145
- pci_free_consistent (ioc -> pcidev , MAX_SGL_BYTES , sglbuf , * sglbuf_dma );
1148
+ dma_free_coherent (& ioc -> pcidev -> dev , MAX_SGL_BYTES , sglbuf ,
1149
+ * sglbuf_dma );
1146
1150
}
1147
1151
kfree (buflist );
1148
1152
return NULL ;
@@ -1162,9 +1166,9 @@ kfree_sgl(MptSge_t *sgl, dma_addr_t sgl_dma, struct buflist *buflist, MPT_ADAPTE
1162
1166
int n = 0 ;
1163
1167
1164
1168
if (sg -> FlagsLength & 0x04000000 )
1165
- dir = PCI_DMA_TODEVICE ;
1169
+ dir = DMA_TO_DEVICE ;
1166
1170
else
1167
- dir = PCI_DMA_FROMDEVICE ;
1171
+ dir = DMA_FROM_DEVICE ;
1168
1172
1169
1173
nib = (sg -> FlagsLength & 0xF0000000 ) >> 28 ;
1170
1174
while (! (nib & 0x4 )) { /* eob */
@@ -1179,8 +1183,10 @@ kfree_sgl(MptSge_t *sgl, dma_addr_t sgl_dma, struct buflist *buflist, MPT_ADAPTE
1179
1183
dma_addr = sg -> Address ;
1180
1184
kptr = bl -> kptr ;
1181
1185
len = bl -> len ;
1182
- pci_unmap_single (ioc -> pcidev , dma_addr , len , dir );
1183
- pci_free_consistent (ioc -> pcidev , len , kptr , dma_addr );
1186
+ dma_unmap_single (& ioc -> pcidev -> dev , dma_addr , len ,
1187
+ dir );
1188
+ dma_free_coherent (& ioc -> pcidev -> dev , len , kptr ,
1189
+ dma_addr );
1184
1190
n ++ ;
1185
1191
}
1186
1192
sg ++ ;
@@ -1197,12 +1203,12 @@ kfree_sgl(MptSge_t *sgl, dma_addr_t sgl_dma, struct buflist *buflist, MPT_ADAPTE
1197
1203
dma_addr = sg -> Address ;
1198
1204
kptr = bl -> kptr ;
1199
1205
len = bl -> len ;
1200
- pci_unmap_single ( ioc -> pcidev , dma_addr , len , dir );
1201
- pci_free_consistent ( ioc -> pcidev , len , kptr , dma_addr );
1206
+ dma_unmap_single ( & ioc -> pcidev -> dev , dma_addr , len , dir );
1207
+ dma_free_coherent ( & ioc -> pcidev -> dev , len , kptr , dma_addr );
1202
1208
n ++ ;
1203
1209
}
1204
1210
1205
- pci_free_consistent ( ioc -> pcidev , MAX_SGL_BYTES , sgl , sgl_dma );
1211
+ dma_free_coherent ( & ioc -> pcidev -> dev , MAX_SGL_BYTES , sgl , sgl_dma );
1206
1212
kfree (buflist );
1207
1213
dctlprintk (ioc , printk (MYIOC_s_DEBUG_FMT "-SG: Free'd 1 SGL buf + %d kbufs!\n" ,
1208
1214
ioc -> name , n ));
@@ -2100,8 +2106,9 @@ mptctl_do_mpt_command (MPT_ADAPTER *ioc, struct mpt_ioctl_command karg, void __u
2100
2106
}
2101
2107
flagsLength |= karg .dataOutSize ;
2102
2108
bufOut .len = karg .dataOutSize ;
2103
- bufOut .kptr = pci_alloc_consistent (
2104
- ioc -> pcidev , bufOut .len , & dma_addr_out );
2109
+ bufOut .kptr = dma_alloc_coherent (& ioc -> pcidev -> dev ,
2110
+ bufOut .len ,
2111
+ & dma_addr_out , GFP_KERNEL );
2105
2112
2106
2113
if (bufOut .kptr == NULL ) {
2107
2114
rc = - ENOMEM ;
@@ -2134,8 +2141,9 @@ mptctl_do_mpt_command (MPT_ADAPTER *ioc, struct mpt_ioctl_command karg, void __u
2134
2141
flagsLength |= karg .dataInSize ;
2135
2142
2136
2143
bufIn .len = karg .dataInSize ;
2137
- bufIn .kptr = pci_alloc_consistent (ioc -> pcidev ,
2138
- bufIn .len , & dma_addr_in );
2144
+ bufIn .kptr = dma_alloc_coherent (& ioc -> pcidev -> dev ,
2145
+ bufIn .len ,
2146
+ & dma_addr_in , GFP_KERNEL );
2139
2147
2140
2148
if (bufIn .kptr == NULL ) {
2141
2149
rc = - ENOMEM ;
@@ -2283,13 +2291,13 @@ mptctl_do_mpt_command (MPT_ADAPTER *ioc, struct mpt_ioctl_command karg, void __u
2283
2291
/* Free the allocated memory.
2284
2292
*/
2285
2293
if (bufOut .kptr != NULL ) {
2286
- pci_free_consistent ( ioc -> pcidev ,
2287
- bufOut . len , (void * ) bufOut .kptr , dma_addr_out );
2294
+ dma_free_coherent ( & ioc -> pcidev -> dev , bufOut . len ,
2295
+ (void * )bufOut .kptr , dma_addr_out );
2288
2296
}
2289
2297
2290
2298
if (bufIn .kptr != NULL ) {
2291
- pci_free_consistent ( ioc -> pcidev ,
2292
- bufIn . len , (void * ) bufIn .kptr , dma_addr_in );
2299
+ dma_free_coherent ( & ioc -> pcidev -> dev , bufIn . len ,
2300
+ (void * )bufIn .kptr , dma_addr_in );
2293
2301
}
2294
2302
2295
2303
/* mf is null if command issued successfully
@@ -2395,7 +2403,9 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)
2395
2403
/* Issue the second config page request */
2396
2404
cfg .action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT ;
2397
2405
2398
- pbuf = pci_alloc_consistent (ioc -> pcidev , hdr .PageLength * 4 , & buf_dma );
2406
+ pbuf = dma_alloc_coherent (& ioc -> pcidev -> dev ,
2407
+ hdr .PageLength * 4 ,
2408
+ & buf_dma , GFP_KERNEL );
2399
2409
if (pbuf ) {
2400
2410
cfg .physAddr = buf_dma ;
2401
2411
if (mpt_config (ioc , & cfg ) == 0 ) {
@@ -2405,7 +2415,9 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)
2405
2415
pdata -> BoardTracerNumber , 24 );
2406
2416
}
2407
2417
}
2408
- pci_free_consistent (ioc -> pcidev , hdr .PageLength * 4 , pbuf , buf_dma );
2418
+ dma_free_coherent (& ioc -> pcidev -> dev ,
2419
+ hdr .PageLength * 4 , pbuf ,
2420
+ buf_dma );
2409
2421
pbuf = NULL ;
2410
2422
}
2411
2423
}
@@ -2470,7 +2482,7 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)
2470
2482
else
2471
2483
IstwiRWRequest -> DeviceAddr = 0xB0 ;
2472
2484
2473
- pbuf = pci_alloc_consistent ( ioc -> pcidev , 4 , & buf_dma );
2485
+ pbuf = dma_alloc_coherent ( & ioc -> pcidev -> dev , 4 , & buf_dma , GFP_KERNEL );
2474
2486
if (!pbuf )
2475
2487
goto out ;
2476
2488
ioc -> add_sge ((char * )& IstwiRWRequest -> SGL ,
@@ -2519,7 +2531,7 @@ mptctl_hp_hostinfo(MPT_ADAPTER *ioc, unsigned long arg, unsigned int data_size)
2519
2531
SET_MGMT_MSG_CONTEXT (ioc -> ioctl_cmds .msg_context , 0 );
2520
2532
2521
2533
if (pbuf )
2522
- pci_free_consistent ( ioc -> pcidev , 4 , pbuf , buf_dma );
2534
+ dma_free_coherent ( & ioc -> pcidev -> dev , 4 , pbuf , buf_dma );
2523
2535
2524
2536
/* Copy the data from kernel memory to user memory
2525
2537
*/
@@ -2585,7 +2597,8 @@ mptctl_hp_targetinfo(MPT_ADAPTER *ioc, unsigned long arg)
2585
2597
/* Get the data transfer speeds
2586
2598
*/
2587
2599
data_sz = ioc -> spi_data .sdp0length * 4 ;
2588
- pg0_alloc = pci_alloc_consistent (ioc -> pcidev , data_sz , & page_dma );
2600
+ pg0_alloc = dma_alloc_coherent (& ioc -> pcidev -> dev , data_sz , & page_dma ,
2601
+ GFP_KERNEL );
2589
2602
if (pg0_alloc ) {
2590
2603
hdr .PageVersion = ioc -> spi_data .sdp0version ;
2591
2604
hdr .PageLength = data_sz ;
@@ -2623,7 +2636,8 @@ mptctl_hp_targetinfo(MPT_ADAPTER *ioc, unsigned long arg)
2623
2636
karg .negotiated_speed = HP_DEV_SPEED_ASYNC ;
2624
2637
}
2625
2638
2626
- pci_free_consistent (ioc -> pcidev , data_sz , (u8 * ) pg0_alloc , page_dma );
2639
+ dma_free_coherent (& ioc -> pcidev -> dev , data_sz , (u8 * )pg0_alloc ,
2640
+ page_dma );
2627
2641
}
2628
2642
2629
2643
/* Set defaults
@@ -2649,7 +2663,8 @@ mptctl_hp_targetinfo(MPT_ADAPTER *ioc, unsigned long arg)
2649
2663
/* Issue the second config page request */
2650
2664
cfg .action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT ;
2651
2665
data_sz = (int ) cfg .cfghdr .hdr -> PageLength * 4 ;
2652
- pg3_alloc = pci_alloc_consistent (ioc -> pcidev , data_sz , & page_dma );
2666
+ pg3_alloc = dma_alloc_coherent (& ioc -> pcidev -> dev , data_sz ,
2667
+ & page_dma , GFP_KERNEL );
2653
2668
if (pg3_alloc ) {
2654
2669
cfg .physAddr = page_dma ;
2655
2670
cfg .pageAddr = (karg .hdr .channel << 8 ) | karg .hdr .id ;
@@ -2658,7 +2673,8 @@ mptctl_hp_targetinfo(MPT_ADAPTER *ioc, unsigned long arg)
2658
2673
karg .phase_errors = (u32 ) le16_to_cpu (pg3_alloc -> PhaseErrorCount );
2659
2674
karg .parity_errors = (u32 ) le16_to_cpu (pg3_alloc -> ParityErrorCount );
2660
2675
}
2661
- pci_free_consistent (ioc -> pcidev , data_sz , (u8 * ) pg3_alloc , page_dma );
2676
+ dma_free_coherent (& ioc -> pcidev -> dev , data_sz ,
2677
+ (u8 * )pg3_alloc , page_dma );
2662
2678
}
2663
2679
}
2664
2680
hd = shost_priv (ioc -> sh );
0 commit comments