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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fac10841-1682-845f-3e4a-5668f59caed0@gmail.com>
Date:   Mon, 22 Aug 2022 23:33:23 +0300
From:   Dmitry Osipenko <digetx@...il.com>
To:     Akhil R <akhilrajeev@...dia.com>,
        Dmitry Osipenko <dmitry.osipenko@...labora.com>,
        "robh+dt@...nel.org" <robh+dt@...nel.org>,
        "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
        "christian.koenig@....com" <christian.koenig@....com>,
        Jonathan Hunter <jonathanh@...dia.com>,
        Laxman Dewangan <ldewangan@...dia.com>,
        "linux-i2c@...r.kernel.org" <linux-i2c@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-tegra@...r.kernel.org" <linux-tegra@...r.kernel.org>,
        "sumit.semwal@...aro.org" <sumit.semwal@...aro.org>,
        "thierry.reding@...il.com" <thierry.reding@...il.com>,
        "wsa@...nel.org" <wsa@...nel.org>
Subject: Re: [PATCH RESEND 1/2] i2c: tegra: Add GPCDMA support

22.08.2022 13:29, Akhil R пишет:
>> On 8/22/22 09:56, Akhil R wrote:
>>>> 19.08.2022 18:15, Dmitry Osipenko пишет:
>>>>> 19.08.2022 15:23, Akhil R пишет:
>>>>>>      if (of_device_is_compatible(np, "nvidia,tegra210-i2c-vi"))
>>>>>>              i2c_dev->is_vi = true;
>>>>>> +    else
>>>>>> +            i2c_dev->dma_support = !!(of_find_property(np, "dmas",
>>>>>> + NULL));
>>>>>
>>>>> 1. You leak the np returned by of_find_property().
>>>>>
>>>>> 2. There is device_property_read_bool() for this kind of
>>>>> property-exists checks.
>>> Okay. I went by the implementation in of_dma_request_slave_channel() to
>>> check 'dmas'.
>>>
>>>>>
>>>>> 3. If "dmas" is missing in DT, then dma_request_chan() should return
>>>>> NULL and everything will work fine. I suppose you haven't tried to
>>>>> test this code.
>>>>
>>>> Although, no. It should return ERR_PTR(-ENODEV) and then you should check
>>>> the return code.
>>> Yes. Agree that it is more agnostic to check for ERR_PTR(-ENODEV). But since I
>>> call tegra_init_dma() for every large transfer until DMA is initialized, wouldn't
>>> it be better to have a flag inside the driver so that we do not have to go
>> through
>>> so many functions for every attempted DMA transaction to find out that the
>> DT
>>> properties don't exist?
>>>
>>> Shall I just put i2c_dev->dma_support = true here since DMA is supported by
>>> hardware? It would turn false if dma_request_chan() returns something other
>>> than -EPROBE_DEFER.
>>>
>>>       if (of_device_is_compatible(np, "nvidia,tegra210-i2c-vi"))
>>>               i2c_dev->is_vi = true;
>>>  +    else
>>>  +            i2c_dev->dma_support = true;
>>
>> The code already has dma_mode for that. I don't see why another variable
>> is needed.
>>
>> Either add new generic dma_request_chan_optional() that will return NULL
>> if channel is not available and make Tegra I2C driver to use it, or
>> handle the error code returned by dma_request_chan().
> 
> Let me elaborate my thoughts. 
> 
> The function tegra_i2c_init_dma() is also called inside tegra_i2c_xfer_msg() if
> DMA is not initialized before, i.e. if (!i2c_dev->dma_buf).

This is not true

i2c_dev->dma_mode=false if !i2c_dev->dma_buf and that's it

https://elixir.bootlin.com/linux/v6.0-rc2/source/drivers/i2c/busses/i2c-tegra.c#L1253

tegra_i2c_init_dma() is invoked only during probe

> So, if suppose there is no DT entry for dmas, the driver would have to go take the
> path tegra_i2c_init_dma() -> dma_request_chan() -> of_*() apis -> ... and then figure
> out that DMA is not supported. This would happen for each transfer of size larger than
> I2C_PIO_MODE_PREFERRED_LEN.
> 
> To avoid this, I am looking for a variable/flag which can indicate if the driver should attempt
> to configure DMA or not. I didn't quite get the idea if dma_mode can be extended to support
> this, because it is updated based on xfer_size on each transfer. My idea of i2c_dev->dma_support
> is that it will be constant after the probe().


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ