Re: [PATCH] i2c: at91: use dma safe buffers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 2022-04-05 15:58, schrieb Codrin.Ciubotariu@xxxxxxxxxxxxx:
On 05.04.2022 14:09, Michael Walle wrote:
Am 2022-04-05 12:02, schrieb Codrin.Ciubotariu@xxxxxxxxxxxxx:
On 05.04.2022 12:38, Michael Walle wrote:
Am 2022-04-05 11:23, schrieb Codrin.Ciubotariu@xxxxxxxxxxxxx:
+       if (dev->use_dma) {
+               dma_buf = i2c_get_dma_safe_msg_buf(m_start, 1);

If you want, you could just dev->buf = i2c_get_dma_safe...

But where is the error handling in that case? dev->buf will
be NULL, which is eventually passed to dma_map_single().

Also, I need the dma_buf for the i2c_put_dma_safe_msg_buf()
call anyway, because dev->buf will be modified during
processing.

You still:
      if (!dev->buf) {
              ret = -ENOMEM;
              goto out;
      }

So, at91_do_twi_transfer()/dma_map_single() will not be called.

Ahh, I misunderstood you. Yes, but as I said, I need the dma_buf
temporary variable anyway, because dev->buf is modified, eg. see
at91_twi_read_data_dma_callback().
at91_twi_read_data_dma_callback() is called as callback if
dma_async_issue_pending(dma->chan_rx) is called.
dma_async_issue_pending(dma->chan_rx) is called on
at91_twi_read_data_dma(), which is called in at91_do_twi_transfer(),
which we decided above to skip in case of error.

It is not about errors, you need the exact same pointer you
got from i2c_get_dma_safe_msg_buf() to be passed to
i2c_put_dma_safe_msg_buf(). And because (in some cases, it
isn't really obvious) the dev->buf will be advanced a few
bytes, I cannot pass dev->buf to i2c_put_dma_safe_msg_buf().

-michael



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux