lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Mon, 24 Jun 2013 01:11:31 -0700 (PDT)
From:	Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
To:	Vinod Koul <vinod.koul@...el.com>
Cc:	Guennadi <g.liakhovetski@....de>, (igel) hayama <taki@...l.co.jp>,
	(igel) damian <dhobsong@...l.co.jp>,
	(RSO) shimoda <yoshihiro.shimoda.uh@...esas.com>,
	(RSO) munakata <hisao.munakata.vt@...esas.com>,
	linux-kernel@...r.kernel.org
Subject: How to get actual received data size on DMAEngine ?


Hi Vinod, and all
Cc Guennadi

I need your opinion

Now, my USB driver is using DMAEngine,
but, in "data receive" case, it doesn't know the exact received data size
before DMA starting, since USB device doesn't know how many data will be sent.
Then, (I think) USB driver is using enough size buffer for it.

Now, our USB-DMAC will stop if
1) specified size transfer was done, or 2) if it got short packet

pseudo code is like this...

   buf = 2048 byte // enough size
   dma_start(buf, size);

   if 1) case
      actual received size was 2048 byte
   if 2) case
      actual received size was 800 byte for example

Now, I need to get this "actual received data size" somehow

Guennadi noticed that dmaengine_tx_status() can return dma_tx_state::residue.
According to the header file, residue should only be returned,
if the transfer is still in progress or has been paused.
But it can help me if we can extend this API to also allow setting
this value for completed transfers.

The pseudo code which can help me is above.
But what do you think about it ?
Or do you have any other solution ?

void dma_done()
{
     /*
      * Now DMA transfer has done
      * this struct dma_tx_state::residue means
      * "real" residue
      */
     dmaengine_tx_status(..., &status);

     if (status->residue > 0) {
         /*
          * 2) case can come here.
          * if actual transferred data was 800,
          * status->residue is (2048 - 800)
          */
     }
}

void my_dma_start()
{
    len = 2048; // for example

    desc = dmaengine_prep_slave_single(..., len, ...);

    desc->callback = dma_done;

    dmaengine_submit(desc);

}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ