@@ -272,6 +272,7 @@ struct stm32_fmc2_nfc {
272
272
struct sg_table dma_data_sg ;
273
273
struct sg_table dma_ecc_sg ;
274
274
u8 * ecc_buf ;
275
+ dma_addr_t dma_ecc_addr ;
275
276
int dma_ecc_len ;
276
277
u32 tx_dma_max_burst ;
277
278
u32 rx_dma_max_burst ;
@@ -902,17 +903,10 @@ static int stm32_fmc2_nfc_xfer(struct nand_chip *chip, const u8 *buf,
902
903
903
904
if (!write_data && !raw ) {
904
905
/* Configure DMA ECC status */
905
- p = nfc -> ecc_buf ;
906
906
for_each_sg (nfc -> dma_ecc_sg .sgl , sg , eccsteps , s ) {
907
- sg_set_buf (sg , p , nfc -> dma_ecc_len );
908
- p += nfc -> dma_ecc_len ;
909
- }
910
-
911
- ret = dma_map_sg (nfc -> dev , nfc -> dma_ecc_sg .sgl ,
912
- eccsteps , dma_data_dir );
913
- if (!ret ) {
914
- ret = - EIO ;
915
- goto err_unmap_data ;
907
+ sg_dma_address (sg ) = nfc -> dma_ecc_addr +
908
+ s * nfc -> dma_ecc_len ;
909
+ sg_dma_len (sg ) = nfc -> dma_ecc_len ;
916
910
}
917
911
918
912
desc_ecc = dmaengine_prep_slave_sg (nfc -> dma_ecc_ch ,
@@ -921,15 +915,15 @@ static int stm32_fmc2_nfc_xfer(struct nand_chip *chip, const u8 *buf,
921
915
DMA_PREP_INTERRUPT );
922
916
if (!desc_ecc ) {
923
917
ret = - ENOMEM ;
924
- goto err_unmap_ecc ;
918
+ goto err_unmap_data ;
925
919
}
926
920
927
921
reinit_completion (& nfc -> dma_ecc_complete );
928
922
desc_ecc -> callback = stm32_fmc2_nfc_dma_callback ;
929
923
desc_ecc -> callback_param = & nfc -> dma_ecc_complete ;
930
924
ret = dma_submit_error (dmaengine_submit (desc_ecc ));
931
925
if (ret )
932
- goto err_unmap_ecc ;
926
+ goto err_unmap_data ;
933
927
934
928
dma_async_issue_pending (nfc -> dma_ecc_ch );
935
929
}
@@ -949,7 +943,7 @@ static int stm32_fmc2_nfc_xfer(struct nand_chip *chip, const u8 *buf,
949
943
if (!write_data && !raw )
950
944
dmaengine_terminate_all (nfc -> dma_ecc_ch );
951
945
ret = - ETIMEDOUT ;
952
- goto err_unmap_ecc ;
946
+ goto err_unmap_data ;
953
947
}
954
948
955
949
/* Wait DMA data transfer completion */
@@ -969,11 +963,6 @@ static int stm32_fmc2_nfc_xfer(struct nand_chip *chip, const u8 *buf,
969
963
}
970
964
}
971
965
972
- err_unmap_ecc :
973
- if (!write_data && !raw )
974
- dma_unmap_sg (nfc -> dev , nfc -> dma_ecc_sg .sgl ,
975
- eccsteps , dma_data_dir );
976
-
977
966
err_unmap_data :
978
967
dma_unmap_sg (nfc -> dev , nfc -> dma_data_sg .sgl , eccsteps , dma_data_dir );
979
968
@@ -1610,7 +1599,8 @@ static int stm32_fmc2_nfc_dma_setup(struct stm32_fmc2_nfc *nfc)
1610
1599
return ret ;
1611
1600
1612
1601
/* Allocate a buffer to store ECC status registers */
1613
- nfc -> ecc_buf = devm_kzalloc (nfc -> dev , FMC2_MAX_ECC_BUF_LEN , GFP_KERNEL );
1602
+ nfc -> ecc_buf = dmam_alloc_coherent (nfc -> dev , FMC2_MAX_ECC_BUF_LEN ,
1603
+ & nfc -> dma_ecc_addr , GFP_KERNEL );
1614
1604
if (!nfc -> ecc_buf )
1615
1605
return - ENOMEM ;
1616
1606
0 commit comments