From: Vladislav B. <vs...@vl...> - 2016-09-28 05:17:49
|
Hi Praveen, Praveen Gokina wrote on 09/27/2016 10:05 PM: > Hi Vlad, > > We are handling reutrn value of pci_map_sg() > > io->tgt_io.seg_cnt = pci_map_sg(io->ocs->ocs_os.pdev, io->tgt_io.sg, io->tgt_io.sg_cnt, > scst_to_tgt_dma_dir(scst_cmd_get_data_direction(cmd))); > > Please let me know if we need to initialize anything in driver before calling > pci_map_sg() ? You need to initialize pdev you are sending to pci_map_sg(). How to do this is quite a big and HW specific topic. I'm afraid, I can't help much here. I would suggest you to grep pci_map_sg and dma_map_sg in Documentation subdirectory of your kernel sources tree. Vlad > Thanks, > Praveen. > > On Wed, Sep 28, 2016 at 10:27 AM, Vladislav Bolkhovitin <vs...@vl... > <mailto:vs...@vl...>> wrote: > > > Praveen Gokina wrote on 09/27/2016 09:48 PM: > > Hi Vlad, > > > > We are calling pci_map_sg > > > > > > io->tgt_io.sg <http://tgt_io.sg> <http://tgt_io.sg> = scst_cmd_get_sg(cmd); > > io->tgt_io.sg_cnt = scst_cmd_get_sg_cnt(cmd); > > io->tgt_io.bufflen = scst_cmd_get_bufflen(cmd); > > io->tgt_io.is_read = scst_cmd_get_data_direction(cmd) != SCST_DATA_WRITE > ? 1 : 0; > > > > pci_map_sg(io->ocs->ocs_os.pdev, io->tgt_io.sg <http://tgt_io.sg>, io->tgt_io.sg_cnt, > > scst_to_tgt_dma_dir(scst_cmd_get_data_direction(cmd))); > > Then after pci_map_sg() sg_dma_len() should return correct value, or it would be a bug > in the kernel DMA subsystem, or, probably, you might not initialize it fully correctly. > SCST does not anyhow touch those DMA SG values. > > BTW, you can not ignore pci_map_sg() return value, it returns number of mapped SG > entries. > > Vlad > > > Thanks, > > Praveen. > > > > > > On Wed, Sep 28, 2016 at 10:14 AM, Vladislav Bolkhovitin <vs...@vl... > <mailto:vs...@vl...> > > <mailto:vs...@vl... <mailto:vs...@vl...>>> wrote: > > > > Hi Praveen, > > > > In order sg_dma_len() return correct result you need at firs map your sg by > > pci_map_sg()/dma_map_sg(). Have you done this? > > > > Vlad > > > > Praveen Gokina wrote on 09/27/2016 08:35 PM: > > > In rdy_to_xfer() driver function, > > > > > > we are getting bufflen as 0x200 ( 512 bytes ) as returned by > > scst_cmd_get_bufflen(cmd); > > > > > > From the SGL, > > > sg = scst_cmd_get_sg(cmd); > > > sg_dma_len(sg) is coming as 0x400 ( 1024 bytes ). > > > > > > bufflen is coming correctly as 512 bytes. Whereas sg_dma_len(sg) is coming > as 0x400 ( > > > 1024 bytes ). > > > > > > Does driver need to call any other function to get correct sg->length ? |