On Thu, May 27, 2021 at 1:06 PM Henk Medenblik <iio-developer@xxxxxxxxxx> wrote: > > Dear Alexandru, > > > That should be happening in drivers/iio/industrialio-buffer.c in the > > iio_enable_buffers() function. > > The channels get enabled by writing via sysfs in > > /sys/bus/iiio/devices/iio:deviceX/scan_elements in the _en files. > > > > libiio typically does this manipulation of files for you > > I thought so too and I can confirm that when I switch back to less > channels that the others are disabled. However the scanmask is not updated. > > See some logging here trying to debug: > > Session 1, read 8 channels: > > iio_readdev -b 262144 -s 1024 iio:device0 voltage0 voltage1 voltage2 > voltage3 voltage4 voltage5 voltage6 voltage7 > /mnt/test6.bin > 8 active channels > [ 513.529510] acq_buffer_preenable > [ 513.529521] active scan mask: 0x000000FF > [ 513.558286] acq_buffer_postenable > [ 513.716868] acq_buffer_predisable > > Session 2, read 16 channels: > > iio_readdev -b 262144 -s 1024 iio:device0 voltage0 voltage1 voltage2 > voltage3 voltage4 voltage5 voltage6 voltage7 voltage8 voltage9 voltage10 > voltage11 voltage12 voltage13 voltage14 voltage15 > /mnt/test6.bin > 16 active channels > [ 523.834056] acq_buffer_preenable > [ 523.834067] active scan mask: 0x0000FFFF > [ 523.880440] acq_buffer_postenable > [ 524.041383] acq_buffer_predisable > > > Session3 , read 8 channels again: > > iio_readdev -b 262144 -s 1024 iio:device0 voltage0 voltage1 voltage2 > voltage3 voltage4 voltage5 voltage6 voltage7 > /mnt/test6.bin > 8 active channels > [ 532.002019] acq_buffer_preenable > [ 532.002030] active scan mask: 0x0000FFFF > [ 532.048375] onr_acq_buffer_postenable > [ 532.131081] onr_acq_buffer_predisable > > > > so, are you using an Analog Devices kernel? > > or is this a vanilla mainline kernel? and which version? > > ADI has some custom patches that deal with this some scanmask manipulation; > > is this being reproduced purely with libiio? and which version of libiio? > > steps to reproduce? > > > > i'm still not sure if the issue is in kernel or in libiio; > > > Yes I am using a adi 4.14 kernel, git tag adi-4.14.0 15e1a16477 > > For iio_readdev I am currently using the v0.21 zerocopy checkout 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. > > Henk > >