Re: active_scan_mask

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

 



On 6/9/21 11:37 AM, Henk Medenblik wrote:
I agree,

The patch works.
@Lars, can you create the patch and push it in your analog devices kernel tree sources ?

Hi,

I can't :) But I'm sure Nuno will be able to do it.

- Lars


Regards

Henk

On 6/9/21 10:55 AM, Lars-Peter Clausen wrote:
On 6/9/21 10:19 AM, Sa, Nuno wrote:
Hi Henk,

From: Henk Medenblik <iio-developer@xxxxxxxxxx>
Sent: Wednesday, June 9, 2021 9:04 AM
To: Alexandru Ardelean <ardeleanalex@xxxxxxxxx>; Henk Medenblik
<iio-developer@xxxxxxxxxx>
Cc: linux-iio <linux-iio@xxxxxxxxxxxxxxx>
Subject: Re: active_scan_mask

[External]

Dear Alexandru,

Hmm, so the "zerocopy" branch isn't at v0.21.
It's something much older [ ~6 years ? ].
Though the kernel active scan mask is unrelated to libiio, since
iio_readdev is being used in different sessions.

The 4.14 version of the kernel, isn't quite new.
There was some recent fix with regards to active scan-mask
computation.
But I am not sure if it's related to this.

Will try to make some time to do some testing on this.

I believe it is a bug which still exists in the adi linux kernel sources.
In industrialio-buffer.c :

static int iio_channel_mask_clear(struct iio_dev *indio_dev,
      struct iio_buffer *buffer, int bit)
{
      unsigned int ch;

      clear_bit(bit, buffer->channel_mask);

      memset(buffer->scan_mask, 0,
BITS_TO_LONGS(indio_dev->masklength));  <---------
      for_each_set_bit(ch, buffer->channel_mask, indio_dev-
num_channels)
          set_bit(indio_dev->channels[ch].scan_index, buffer-
scan_mask);
      return 0;
}

Take a look at [1] for more details. Long story short, I think this is here because we have some devices where we have bit granularity. Hence, we map all channels to the same scan_index and to distinguish which channels are enabled, we could not use the current upstream implementation. I remember some talks about this but not actual patches came from it (I will have to go over those emails to see if I can come up with some
patches).

Regarding the memset, that looks like a bug. I guess we want:

memset(buffer->scan_mask, 0, BITS_TO_LONGS(indio_dev->masklength) * sizeof(*buffer->scan_mask));

Ccing Lars as he implemented this patches and might have something to add to
your questions.

Yea, my fault, sorry. The patch looks good.





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux