From: Fabio Estevam festevam@denx.de
Since commit 2718f15403fb ("iio: sanity check available_scan_masks array"), verbose and misleading warnings are printed for devices like the MAX11601:
max1363 1-0064: available_scan_mask 8 subset of 0. Never used max1363 1-0064: available_scan_mask 9 subset of 0. Never used max1363 1-0064: available_scan_mask 10 subset of 0. Never used max1363 1-0064: available_scan_mask 11 subset of 0. Never used max1363 1-0064: available_scan_mask 12 subset of 0. Never used max1363 1-0064: available_scan_mask 13 subset of 0. Never used ... [warnings continue]
Fix the available_scan_masks sanity check logic so that it only prints the warning when an element of available_scan_mask is in fact a subset of a previous one.
These warnings incorrectly report that later scan masks are subsets of the first one, even when they are not. The issue lies in the logic that checks for subset relationships between scan masks.
Fix the subset detection to correctly compare each mask only against previous masks, and only warn when a true subset is found.
With this fix, the warning output becomes both correct and more informative:
max1363 1-0064: Mask 7 (0xc) is a subset of mask 6 (0xf) and will be ignored
Cc: stable@vger.kernel.org Fixes: 2718f15403fb ("iio: sanity check available_scan_masks array") Signed-off-by: Fabio Estevam festevam@denx.de --- drivers/iio/industrialio-core.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 6a6568d4a2cb..855d5fd3e6b2 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1904,6 +1904,11 @@ static int iio_check_extended_name(const struct iio_dev *indio_dev)
static const struct iio_buffer_setup_ops noop_ring_setup_ops;
+static int is_subset(unsigned long a, unsigned long b) +{ + return (a & ~b) == 0; +} + static void iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev) { unsigned int num_masks, masklength, longs_per_mask; @@ -1947,21 +1952,13 @@ static void iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev) * available masks in the order of preference (presumably the least * costy to access masks first). */ - for (i = 0; i < num_masks - 1; i++) { - const unsigned long *mask1; - int j;
- mask1 = av_masks + i * longs_per_mask; - for (j = i + 1; j < num_masks; j++) { - const unsigned long *mask2; - - mask2 = av_masks + j * longs_per_mask; - if (bitmap_subset(mask2, mask1, masklength)) + for (i = 1; i < num_masks; ++i) + for (int j = 0; j < i; ++j) + if (is_subset(av_masks[i], av_masks[j])) dev_warn(indio_dev->dev.parent, - "available_scan_mask %d subset of %d. Never used\n", - j, i); - } - } + "Mask %d (0x%lx) is a subset of mask %d (0x%lx) and will be ignored\n", + i, av_masks[i], j, av_masks[j]); }
/**
From: Fabio Estevam festevam@denx.de
The IIO core emits warnings when a scan mask is a subset of a previous one in the available_scan_masks array.
In the current max11607_mode_list[], the s0to3 mode (channels 0–3, mask 0xF) precedes the s2to3 mode (channels 2–3, mask 0xC). Since 0xC is a subset of 0xF, the following warning is triggered:
max1363 1-0064: Mask 7 (0xc) is a subset of mask 6 (0xf) and will be ignored
Reordering the max11607_mode_list[] to place s0to3 after s2to3 ensures that more specific scan modes are listed before broader ones, preventing such warnings.
This change improves clarity and avoids unnecessary warnings during device initialization.
Cc: stable@vger.kernel.org Fixes: 2718f15403fb ("iio: sanity check available_scan_masks array") Signed-off-by: Fabio Estevam festevam@denx.de --- drivers/iio/adc/max1363.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index d0c6e94f7204..e8eeb00bef7b 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -577,8 +577,8 @@ static const struct iio_chan_spec max1238_channels[] = MAX1363_12X_CHANS(12);
static const enum max1363_modes max11607_mode_list[] = { _s0, _s1, _s2, _s3, - s0to1, s0to2, s0to3, - s2to3, + s0to1, s0to2, s2to3, + s0to3, d0m1, d2m3, d1m0, d3m2, d0m1to2m3, d1m0to3m2, };
On Tue, 29 Apr 2025 12:02:13 -0300 Fabio Estevam festevam@gmail.com wrote:
From: Fabio Estevam festevam@denx.de
The IIO core emits warnings when a scan mask is a subset of a previous one in the available_scan_masks array.
In the current max11607_mode_list[], the s0to3 mode (channels 0–3, mask 0xF) precedes the s2to3 mode (channels 2–3, mask 0xC). Since 0xC is a subset of 0xF, the following warning is triggered:
max1363 1-0064: Mask 7 (0xc) is a subset of mask 6 (0xf) and will be ignored
Reordering the max11607_mode_list[] to place s0to3 after s2to3 ensures that more specific scan modes are listed before broader ones, preventing such warnings.
This change improves clarity and avoids unnecessary warnings during device initialization.
Cc: stable@vger.kernel.org Fixes: 2718f15403fb ("iio: sanity check available_scan_masks array") Signed-off-by: Fabio Estevam festevam@denx.de
There are others in there that are out of order... max1238_mode_list[] for example looks to be as s6to7 should be before s0to7 (there are more issues with that one).
Would you mind taking a quick look at all those others as I'd like one fix for all of them if possible?
Thanks,
Jonathan
drivers/iio/adc/max1363.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index d0c6e94f7204..e8eeb00bef7b 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -577,8 +577,8 @@ static const struct iio_chan_spec max1238_channels[] = MAX1363_12X_CHANS(12); static const enum max1363_modes max11607_mode_list[] = { _s0, _s1, _s2, _s3,
- s0to1, s0to2, s0to3,
- s2to3,
- s0to1, s0to2, s2to3,
- s0to3, d0m1, d2m3, d1m0, d3m2, d0m1to2m3, d1m0to3m2,
};
On Tue, Apr 29, 2025 at 2:35 PM Jonathan Cameron jic23@kernel.org wrote:
There are others in there that are out of order... max1238_mode_list[] for example looks to be as s6to7 should be before s0to7 (there are more issues with that one).
Would you mind taking a quick look at all those others as I'd like one fix for all of them if possible?
Yes, I can fix all of them.
On Tue, 29 Apr 2025 12:02:12 -0300 Fabio Estevam festevam@gmail.com wrote:
From: Fabio Estevam festevam@denx.de
Since commit 2718f15403fb ("iio: sanity check available_scan_masks array"), verbose and misleading warnings are printed for devices like the MAX11601:
max1363 1-0064: available_scan_mask 8 subset of 0. Never used max1363 1-0064: available_scan_mask 9 subset of 0. Never used max1363 1-0064: available_scan_mask 10 subset of 0. Never used max1363 1-0064: available_scan_mask 11 subset of 0. Never used max1363 1-0064: available_scan_mask 12 subset of 0. Never used max1363 1-0064: available_scan_mask 13 subset of 0. Never used ... [warnings continue]
Fix the available_scan_masks sanity check logic so that it only prints the warning when an element of available_scan_mask is in fact a subset of a previous one.
These warnings incorrectly report that later scan masks are subsets of the first one, even when they are not. The issue lies in the logic that checks for subset relationships between scan masks.
Add a little on why the logic is wrong would be good.
I stared at this for a while when you first reported it and couldn't spot it..
Fix the subset detection to correctly compare each mask only against previous masks, and only warn when a true subset is found.
With this fix, the warning output becomes both correct and more informative:
max1363 1-0064: Mask 7 (0xc) is a subset of mask 6 (0xf) and will be ignored
Cc: stable@vger.kernel.org Fixes: 2718f15403fb ("iio: sanity check available_scan_masks array") Signed-off-by: Fabio Estevam festevam@denx.de
drivers/iio/industrialio-core.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 6a6568d4a2cb..855d5fd3e6b2 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1904,6 +1904,11 @@ static int iio_check_extended_name(const struct iio_dev *indio_dev) static const struct iio_buffer_setup_ops noop_ring_setup_ops; +static int is_subset(unsigned long a, unsigned long b) +{
- return (a & ~b) == 0;
+}
static void iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev) { unsigned int num_masks, masklength, longs_per_mask; @@ -1947,21 +1952,13 @@ static void iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev) * available masks in the order of preference (presumably the least * costy to access masks first). */
- for (i = 0; i < num_masks - 1; i++) {
const unsigned long *mask1;
int j;
mask1 = av_masks + i * longs_per_mask;
for (j = i + 1; j < num_masks; j++) {
const unsigned long *mask2;
mask2 = av_masks + j * longs_per_mask;
if (bitmap_subset(mask2, mask1, masklength))
- for (i = 1; i < num_masks; ++i)
for (int j = 0; j < i; ++j)
if (is_subset(av_masks[i], av_masks[j]))
Why move away from the bitmap_subset() call?
There are some broken corners for large bitmaps but I'd rather not make it worse if we can avoid it as the intent is that we can make these larger bitmaps if needed.
dev_warn(indio_dev->dev.parent,
"available_scan_mask %d subset of %d. Never used\n",
j, i);
}
- }
"Mask %d (0x%lx) is a subset of mask %d (0x%lx) and will be ignored\n",
i, av_masks[i], j, av_masks[j]);
} /**
Hi Jonathan,
On Tue, Apr 29, 2025 at 2:33 PM Jonathan Cameron jic23@kernel.org wrote:
Why move away from the bitmap_subset() call?
I added the following debug patch on top of the original code:
--- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1947,15 +1947,23 @@ static void iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev) * available masks in the order of preference (presumably the least * costy to access masks first). */ + + pr_err("******** masklength is %d", masklength); + pr_err("******** longs_per_mask is %d", longs_per_mask); + for (i = 0; i < num_masks - 1; i++) { const unsigned long *mask1; int j;
mask1 = av_masks + i * longs_per_mask; + + pr_err("******** mask1[%d] is 0x%lx\n", i, mask1[i]); + for (j = i + 1; j < num_masks; j++) { const unsigned long *mask2;
mask2 = av_masks + j * longs_per_mask; + pr_err("******** mask2[%d] is 0x%lx\n", j, mask2[i]); if (bitmap_subset(mask2, mask1, masklength)) dev_warn(indio_dev->dev.parent, "available_scan_mask %d subset of %d. Never used\n",
and saw that the current logic for determining when an element is a subset of a previous one is not working correctly:
[ 1.562321] iio-core: ******** masklength is 9 [ 1.562334] iio-core: ******** longs_per_mask is 1 [ 1.566855] iio-core: ******** mask1[0] is 0x1 [ 1.576121] iio-core: ******** mask2[1] is 0x2 [ 1.580577] iio-core: ******** mask2[2] is 0x4 [ 1.585029] iio-core: ******** mask2[3] is 0x8 [ 1.589482] iio-core: ******** mask2[4] is 0x3 [ 1.593936] iio-core: ******** mask2[5] is 0x7 [ 1.598389] iio-core: ******** mask2[6] is 0xf [ 1.602840] iio-core: ******** mask2[7] is 0xc [ 1.607294] iio-core: ******** mask2[8] is 0x1000 [ 1.612013] max1363 1-0064: available_scan_mask 8 subset of 0. Never used [ 1.618814] iio-core: ******** mask2[9] is 0x2000 [ 1.623530] max1363 1-0064: available_scan_mask 9 subset of 0. Never used [ 1.630328] iio-core: ******** mask2[10] is 0x40000 [ 1.635224] max1363 1-0064: available_scan_mask 10 subset of 0. Never used [ 1.642112] iio-core: ******** mask2[11] is 0x80000 [ 1.647001] max1363 1-0064: available_scan_mask 11 subset of 0. Never used [ 1.653886] iio-core: ******** mask2[12] is 0x3000 [ 1.658687] max1363 1-0064: available_scan_mask 12 subset of 0. Never used [ 1.665571] iio-core: ******** mask2[13] is 0xc0000 [ 1.670461] max1363 1-0064: available_scan_mask 13 subset of 0. Never used [ 1.677350] iio-core: ******** mask1[1] is 0x4 [ 1.681811] iio-core: ******** mask2[2] is 0x8 [ 1.686272] iio-core: ******** mask2[3] is 0x3 [ 1.690724] iio-core: ******** mask2[4] is 0x7 [ 1.695175] iio-core: ******** mask2[5] is 0xf [ 1.699626] iio-core: ******** mask2[6] is 0xc [ 1.704078] iio-core: ******** mask2[7] is 0x1000 [ 1.708791] iio-core: ******** mask2[8] is 0x2000 [ 1.713506] max1363 1-0064: available_scan_mask 8 subset of 1. Never used [ 1.720305] iio-core: ******** mask2[9] is 0x40000 [ 1.725106] max1363 1-0064: available_scan_mask 9 subset of 1. Never used [ 1.731903] iio-core: ******** mask2[10] is 0x80000 [ 1.736793] max1363 1-0064: available_scan_mask 10 subset of 1. Never used [ 1.743676] iio-core: ******** mask2[11] is 0x3000 [ 1.748478] max1363 1-0064: available_scan_mask 11 subset of 1. Never used [ 1.755363] iio-core: ******** mask2[12] is 0xc0000 [ 1.760251] max1363 1-0064: available_scan_mask 12 subset of 1. Never used [ 1.767136] iio-core: ******** mask2[13] is 0x0 [ 1.771677] max1363 1-0064: available_scan_mask 13 subset of 1. Never used [ 1.778562] iio-core: ******** mask1[2] is 0x3 [ 1.783015] iio-core: ******** mask2[3] is 0x7 [ 1.787470] iio-core: ******** mask2[4] is 0xf [ 1.791922] iio-core: ******** mask2[5] is 0xc [ 1.796403] iio-core: ******** mask2[6] is 0x1000 [ 1.801116] iio-core: ******** mask2[7] is 0x2000 [ 1.805830] iio-core: ******** mask2[8] is 0x40000 [ 1.810636] max1363 1-0064: available_scan_mask 8 subset of 2. Never used [ 1.817433] iio-core: ******** mask2[9] is 0x80000 [ 1.822235] max1363 1-0064: available_scan_mask 9 subset of 2. Never used [ 1.829033] iio-core: ******** mask2[10] is 0x3000 [ 1.833832] max1363 1-0064: available_scan_mask 10 subset of 2. Never used [ 1.840719] iio-core: ******** mask2[11] is 0xc0000 [ 1.845607] max1363 1-0064: available_scan_mask 11 subset of 2. Never used [ 1.852491] iio-core: ******** mask2[12] is 0x0 [ 1.857029] max1363 1-0064: available_scan_mask 12 subset of 2. Never used [ 1.863915] iio-core: ******** mask2[13] is 0x0 [ 1.868456] max1363 1-0064: available_scan_mask 13 subset of 2. Never used [ 1.875341] iio-core: ******** mask1[3] is 0xf [ 1.879794] iio-core: ******** mask2[4] is 0xc [ 1.884246] iio-core: ******** mask2[5] is 0x1000 [ 1.888960] iio-core: ******** mask2[6] is 0x2000 [ 1.893674] iio-core: ******** mask2[7] is 0x40000 [ 1.898475] iio-core: ******** mask2[8] is 0x80000 [ 1.903276] max1363 1-0064: available_scan_mask 8 subset of 3. Never used [ 1.910074] iio-core: ******** mask2[9] is 0x3000 [ 1.914788] max1363 1-0064: available_scan_mask 9 subset of 3. Never used [ 1.921586] iio-core: ******** mask2[10] is 0xc0000 [ 1.926474] max1363 1-0064: available_scan_mask 10 subset of 3. Never used [ 1.933360] iio-core: ******** mask2[11] is 0x0 [ 1.937906] max1363 1-0064: available_scan_mask 11 subset of 3. Never used [ 1.944794] iio-core: ******** mask2[12] is 0x0 [ 1.949334] max1363 1-0064: available_scan_mask 12 subset of 3. Never used [ 1.956219] iio-core: ******** mask2[13] is 0xffff0000012b5480 [ 1.962063] max1363 1-0064: available_scan_mask 13 subset of 3. Never used [ 1.968948] iio-core: ******** mask1[4] is 0x1000 [ 1.973659] iio-core: ******** mask2[5] is 0x2000 [ 1.978372] iio-core: ******** mask2[6] is 0x40000 [ 1.983172] iio-core: ******** mask2[7] is 0x80000 [ 1.987972] iio-core: ******** mask2[8] is 0x3000 [ 1.992686] max1363 1-0064: available_scan_mask 8 subset of 4. Never used [ 1.999484] iio-core: ******** mask2[9] is 0xc0000 [ 2.004289] max1363 1-0064: available_scan_mask 9 subset of 4. Never used [ 2.011087] iio-core: ******** mask2[10] is 0x0 [ 2.015629] max1363 1-0064: available_scan_mask 10 subset of 4. Never used [ 2.022514] iio-core: ******** mask2[11] is 0x0 [ 2.027054] max1363 1-0064: available_scan_mask 11 subset of 4. Never used [ 2.033939] iio-core: ******** mask2[12] is 0xffff0000012b5480 [ 2.039783] max1363 1-0064: available_scan_mask 12 subset of 4. Never used [ 2.046668] iio-core: ******** mask2[13] is 0xffff0000012b5420 [ 2.052513] max1363 1-0064: available_scan_mask 13 subset of 4. Never used [ 2.059404] iio-core: ******** mask1[5] is 0x40000 [ 2.064203] iio-core: ******** mask2[6] is 0x80000 [ 2.069003] iio-core: ******** mask2[7] is 0x3000 [ 2.073716] iio-core: ******** mask2[8] is 0xc0000 [ 2.078518] max1363 1-0064: available_scan_mask 8 subset of 5. Never used [ 2.085316] iio-core: ******** mask2[9] is 0x0 [ 2.089769] max1363 1-0064: available_scan_mask 9 subset of 5. Never used [ 2.096567] iio-core: ******** mask2[10] is 0x0 [ 2.101107] max1363 1-0064: available_scan_mask 10 subset of 5. Never used [ 2.107993] iio-core: ******** mask2[11] is 0xffff0000012b5480 [ 2.113836] max1363 1-0064: available_scan_mask 11 subset of 5. Never used [ 2.120721] iio-core: ******** mask2[12] is 0xffff0000012b5420 [ 2.126564] max1363 1-0064: available_scan_mask 12 subset of 5. Never used [ 2.133449] iio-core: ******** mask2[13] is 0xffff0000012b53c0 [ 2.139292] max1363 1-0064: available_scan_mask 13 subset of 5. Never used [ 2.146182] iio-core: ******** mask1[6] is 0x3000 [ 2.150898] iio-core: ******** mask2[7] is 0xc0000 [ 2.155699] max1363 1-0064: available_scan_mask 7 subset of 6. Never used [ 2.162499] iio-core: ******** mask2[8] is 0x0 [ 2.166952] max1363 1-0064: available_scan_mask 8 subset of 6. Never used [ 2.173750] iio-core: ******** mask2[9] is 0x0 [ 2.178204] max1363 1-0064: available_scan_mask 9 subset of 6. Never used [ 2.185006] iio-core: ******** mask2[10] is 0xffff0000012b5480 [ 2.190850] max1363 1-0064: available_scan_mask 10 subset of 6. Never used [ 2.197735] iio-core: ******** mask2[11] is 0xffff0000012b5420 [ 2.203578] max1363 1-0064: available_scan_mask 11 subset of 6. Never used [ 2.210463] iio-core: ******** mask2[12] is 0xffff0000012b53c0 [ 2.216307] max1363 1-0064: available_scan_mask 12 subset of 6. Never used [ 2.223194] iio-core: ******** mask2[13] is 0xffff0000012b5360 [ 2.229041] max1363 1-0064: available_scan_mask 13 subset of 6. Never used [ 2.235926] iio-core: ******** mask1[7] is 0x0 [ 2.240378] iio-core: ******** mask2[8] is 0x0 [ 2.244831] max1363 1-0064: available_scan_mask 8 subset of 7. Never used [ 2.251629] iio-core: ******** mask2[9] is 0xffff0000012b5480 [ 2.257385] max1363 1-0064: available_scan_mask 9 subset of 7. Never used [ 2.264183] iio-core: ******** mask2[10] is 0xffff0000012b5420 [ 2.270032] max1363 1-0064: available_scan_mask 10 subset of 7. Never used [ 2.276914] iio-core: ******** mask2[11] is 0xffff0000012b53c0 [ 2.282757] max1363 1-0064: available_scan_mask 11 subset of 7. Never used [ 2.289640] iio-core: ******** mask2[12] is 0xffff0000012b5360 [ 2.295483] max1363 1-0064: available_scan_mask 12 subset of 7. Never used [ 2.302367] iio-core: ******** mask2[13] is 0xffff0000012b5300 [ 2.308215] max1363 1-0064: available_scan_mask 13 subset of 7. Never used [ 2.315101] iio-core: ******** mask1[8] is 0xffff0000012b5480 [ 2.320857] iio-core: ******** mask2[9] is 0xffff0000012b5420 [ 2.326613] max1363 1-0064: available_scan_mask 9 subset of 8. Never used [ 2.333411] iio-core: ******** mask2[10] is 0xffff0000012b53c0 [ 2.339254] max1363 1-0064: available_scan_mask 10 subset of 8. Never used [ 2.346138] iio-core: ******** mask2[11] is 0xffff0000012b5360 [ 2.351981] max1363 1-0064: available_scan_mask 11 subset of 8. Never used [ 2.358867] iio-core: ******** mask2[12] is 0xffff0000012b5300 [ 2.364710] max1363 1-0064: available_scan_mask 12 subset of 8. Never used [ 2.371594] iio-core: ******** mask2[13] is 0xffff0000012b52a0 [ 2.377437] max1363 1-0064: available_scan_mask 13 subset of 8. Never used [ 2.384322] iio-core: ******** mask1[9] is 0xffff0000012b53c0 [ 2.390077] iio-core: ******** mask2[10] is 0xffff0000012b5360 [ 2.395921] max1363 1-0064: available_scan_mask 10 subset of 9. Never used [ 2.402805] iio-core: ******** mask2[11] is 0xffff0000012b5300 [ 2.408648] max1363 1-0064: available_scan_mask 11 subset of 9. Never used [ 2.415533] iio-core: ******** mask2[12] is 0xffff0000012b52a0 [ 2.421376] max1363 1-0064: available_scan_mask 12 subset of 9. Never used [ 2.428262] iio-core: ******** mask2[13] is 0xffff0000012b5240 [ 2.434108] max1363 1-0064: available_scan_mask 13 subset of 9. Never used [ 2.440993] iio-core: ******** mask1[10] is 0xffff0000012b5300 [ 2.446836] iio-core: ******** mask2[11] is 0xffff0000012b52a0 [ 2.452679] max1363 1-0064: available_scan_mask 11 subset of 10. Never used [ 2.459651] iio-core: ******** mask2[12] is 0xffff0000012b5240 [ 2.465494] max1363 1-0064: available_scan_mask 12 subset of 10. Never used [ 2.472466] iio-core: ******** mask2[13] is 0xffff0000012b51e0 [ 2.478309] max1363 1-0064: available_scan_mask 13 subset of 10. Never used [ 2.485281] iio-core: ******** mask1[11] is 0xffff0000012b5240 [ 2.491123] iio-core: ******** mask2[12] is 0xffff0000012b51e0 [ 2.496966] max1363 1-0064: available_scan_mask 12 subset of 11. Never used [ 2.503939] iio-core: ******** mask2[13] is 0xffff0000012b5180 [ 2.509780] max1363 1-0064: available_scan_mask 13 subset of 11. Never used [ 2.516752] iio-core: ******** mask1[12] is 0xffff0000012b5180 [ 2.522594] iio-core: ******** mask2[13] is 0xffff0000012b5120 [ 2.528436] max1363 1-0064: available_scan_mask 13 subset of 12. Never used
That's why I decided to implement a new one that I have validated on a PC.
I am open to suggestions.
Thanks
On Tue, Apr 29, 2025 at 3:33 PM Fabio Estevam festevam@gmail.com wrote:
pr_err("******** mask2[%d] is 0x%lx\n", j, mask2[i]);
Sorry, this line is wrong.
The correct debug patch is this one:
--- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1947,15 +1947,23 @@ static void iio_sanity_check_avail_scan_masks(struct iio_dev *indio_dev) * available masks in the order of preference (presumably the least * costy to access masks first). */ + + pr_err("******** masklength is %d", masklength); + pr_err("******** longs_per_mask is %d", longs_per_mask); + for (i = 0; i < num_masks - 1; i++) { const unsigned long *mask1; int j;
mask1 = av_masks + i * longs_per_mask; + + pr_err("******** mask1[%d] is 0x%lx\n", i, mask1[i]); + for (j = i + 1; j < num_masks; j++) { const unsigned long *mask2;
mask2 = av_masks + j * longs_per_mask; + pr_err("******** mask2[%d] is 0x%lx\n", j, mask2[j]); if (bitmap_subset(mask2, mask1, masklength)) dev_warn(indio_dev->dev.parent, "available_scan_mask %d subset of %d. Never used\n", The original mask array is:
0x1, 0x2, 0x4, 0x8, 0x3, 0x7, 0xf, 0xc, 0x1000, 0x2000, 0x40000, 0x80000, 0x3000, 0xc0000,
So mask2 is jumping by two indexes, instead of one.
mask1 and mask2 arrays are accessing uninitialized data:
[ 1.561626] iio-core: ******** masklength is 9 [ 1.561639] iio-core: ******** longs_per_mask is 1 [ 1.566130] iio-core: ******** mask1[0] is 0x1 [ 1.570945] iio-core: ******** mask2[1] is 0x4 [ 1.584554] iio-core: ******** mask2[2] is 0x3 [ 1.589012] iio-core: ******** mask2[3] is 0xf [ 1.593465] iio-core: ******** mask2[4] is 0x1000 [ 1.598183] iio-core: ******** mask2[5] is 0x40000 [ 1.602981] iio-core: ******** mask2[6] is 0x3000 [ 1.607702] iio-core: ******** mask2[7] is 0x0 [ 1.612157] iio-core: ******** mask2[8] is 0xffff0000000e2720 [ 1.617925] max1363 1-0064: available_scan_mask 8 subset of 0. Never used [ 1.624723] iio-core: ******** mask2[9] is 0xffff0000000e2660 [ 1.630493] max1363 1-0064: available_scan_mask 9 subset of 0. Never used [ 1.637297] iio-core: ******** mask2[10] is 0xffff0000000e25a0 [ 1.643141] max1363 1-0064: available_scan_mask 10 subset of 0. Never used [ 1.650032] iio-core: ******** mask2[11] is 0xffff0000000e24e0 [ 1.655876] max1363 1-0064: available_scan_mask 11 subset of 0. Never used [ 1.662772] iio-core: ******** mask2[12] is 0xffff0000000e2420 [ 1.668614] max1363 1-0064: available_scan_mask 12 subset of 0. Never used [ 1.675506] iio-core: ******** mask2[13] is 0xffff0000000e2360 [ 1.681361] max1363 1-0064: available_scan_mask 13 subset of 0. Never used [ 1.688257] iio-core: ******** mask1[1] is 0x4 [ 1.692725] iio-core: ******** mask2[2] is 0x3 [ 1.697185] iio-core: ******** mask2[3] is 0xf [ 1.701642] iio-core: ******** mask2[4] is 0x1000 [ 1.706361] iio-core: ******** mask2[5] is 0x40000 [ 1.711163] iio-core: ******** mask2[6] is 0x3000 [ 1.715880] iio-core: ******** mask2[7] is 0x0 [ 1.720335] iio-core: ******** mask2[8] is 0xffff0000000e2720 [ 1.726097] max1363 1-0064: available_scan_mask 8 subset of 1. Never used [ 1.732899] iio-core: ******** mask2[9] is 0xffff0000000e2660 [ 1.738659] max1363 1-0064: available_scan_mask 9 subset of 1. Never used [ 1.745463] iio-core: ******** mask2[10] is 0xffff0000000e25a0 [ 1.751307] max1363 1-0064: available_scan_mask 10 subset of 1. Never used [ 1.758197] iio-core: ******** mask2[11] is 0xffff0000000e24e0 [ 1.764044] max1363 1-0064: available_scan_mask 11 subset of 1. Never used [ 1.770933] iio-core: ******** mask2[12] is 0xffff0000000e2420 [ 1.776776] max1363 1-0064: available_scan_mask 12 subset of 1. Never used [ 1.783671] iio-core: ******** mask2[13] is 0xffff0000000e2360 [ 1.789521] max1363 1-0064: available_scan_mask 13 subset of 1. Never used [ 1.796407] iio-core: ******** mask1[2] is 0x3 [ 1.800864] iio-core: ******** mask2[3] is 0xf [ 1.805319] iio-core: ******** mask2[4] is 0x1000 [ 1.810046] iio-core: ******** mask2[5] is 0x40000 [ 1.814848] iio-core: ******** mask2[6] is 0x3000 [ 1.819563] iio-core: ******** mask2[7] is 0x0 [ 1.824014] iio-core: ******** mask2[8] is 0xffff0000000e2720 [ 1.829769] max1363 1-0064: available_scan_mask 8 subset of 2. Never used [ 1.836566] iio-core: ******** mask2[9] is 0xffff0000000e2660 [ 1.842322] max1363 1-0064: available_scan_mask 9 subset of 2. Never used [ 1.849149] iio-core: ******** mask2[10] is 0xffff0000000e25a0 [ 1.854994] max1363 1-0064: available_scan_mask 10 subset of 2. Never used [ 1.861880] iio-core: ******** mask2[11] is 0xffff0000000e24e0 [ 1.867723] max1363 1-0064: available_scan_mask 11 subset of 2. Never used [ 1.874608] iio-core: ******** mask2[12] is 0xffff0000000e2420 [ 1.880452] max1363 1-0064: available_scan_mask 12 subset of 2. Never used [ 1.887339] iio-core: ******** mask2[13] is 0xffff0000000e2360 [ 1.893182] max1363 1-0064: available_scan_mask 13 subset of 2. Never used [ 1.900068] iio-core: ******** mask1[3] is 0xf [ 1.904520] iio-core: ******** mask2[4] is 0x1000 [ 1.909232] iio-core: ******** mask2[5] is 0x40000 [ 1.914033] iio-core: ******** mask2[6] is 0x3000 [ 1.918746] iio-core: ******** mask2[7] is 0x0 [ 1.923200] iio-core: ******** mask2[8] is 0xffff0000000e2720 [ 1.928956] max1363 1-0064: available_scan_mask 8 subset of 3. Never used [ 1.935759] iio-core: ******** mask2[9] is 0xffff0000000e2660 [ 1.941517] max1363 1-0064: available_scan_mask 9 subset of 3. Never used [ 1.948315] iio-core: ******** mask2[10] is 0xffff0000000e25a0 [ 1.954156] max1363 1-0064: available_scan_mask 10 subset of 3. Never used [ 1.961042] iio-core: ******** mask2[11] is 0xffff0000000e24e0 [ 1.966885] max1363 1-0064: available_scan_mask 11 subset of 3. Never used [ 1.973771] iio-core: ******** mask2[12] is 0xffff0000000e2420 [ 1.979614] max1363 1-0064: available_scan_mask 12 subset of 3. Never used [ 1.986499] iio-core: ******** mask2[13] is 0xffff0000000e2360 [ 1.992343] max1363 1-0064: available_scan_mask 13 subset of 3. Never used [ 1.999226] iio-core: ******** mask1[4] is 0x1000 [ 2.003943] iio-core: ******** mask2[5] is 0x40000 [ 2.008743] iio-core: ******** mask2[6] is 0x3000 [ 2.013457] iio-core: ******** mask2[7] is 0x0 [ 2.017910] iio-core: ******** mask2[8] is 0xffff0000000e2720 [ 2.023666] max1363 1-0064: available_scan_mask 8 subset of 4. Never used [ 2.030464] iio-core: ******** mask2[9] is 0xffff0000000e2660 [ 2.036220] max1363 1-0064: available_scan_mask 9 subset of 4. Never used [ 2.043019] iio-core: ******** mask2[10] is 0xffff0000000e25a0 [ 2.048863] max1363 1-0064: available_scan_mask 10 subset of 4. Never used [ 2.055748] iio-core: ******** mask2[11] is 0xffff0000000e24e0 [ 2.061596] max1363 1-0064: available_scan_mask 11 subset of 4. Never used [ 2.068482] iio-core: ******** mask2[12] is 0xffff0000000e2420 [ 2.074326] max1363 1-0064: available_scan_mask 12 subset of 4. Never used [ 2.081212] iio-core: ******** mask2[13] is 0xffff0000000e2360 [ 2.087055] max1363 1-0064: available_scan_mask 13 subset of 4. Never used [ 2.093938] iio-core: ******** mask1[5] is 0x40000 [ 2.098739] iio-core: ******** mask2[6] is 0x3000 [ 2.103452] iio-core: ******** mask2[7] is 0x0 [ 2.107905] iio-core: ******** mask2[8] is 0xffff0000000e2720 [ 2.113661] max1363 1-0064: available_scan_mask 8 subset of 5. Never used [ 2.120459] iio-core: ******** mask2[9] is 0xffff0000000e2660 [ 2.126215] max1363 1-0064: available_scan_mask 9 subset of 5. Never used [ 2.133013] iio-core: ******** mask2[10] is 0xffff0000000e25a0 [ 2.138857] max1363 1-0064: available_scan_mask 10 subset of 5. Never used [ 2.145750] iio-core: ******** mask2[11] is 0xffff0000000e24e0 [ 2.151595] max1363 1-0064: available_scan_mask 11 subset of 5. Never used [ 2.158480] iio-core: ******** mask2[12] is 0xffff0000000e2420 [ 2.164323] max1363 1-0064: available_scan_mask 12 subset of 5. Never used [ 2.171208] iio-core: ******** mask2[13] is 0xffff0000000e2360 [ 2.177051] max1363 1-0064: available_scan_mask 13 subset of 5. Never used [ 2.183936] iio-core: ******** mask1[6] is 0x3000 [ 2.188654] iio-core: ******** mask2[7] is 0x0 [ 2.193106] max1363 1-0064: available_scan_mask 7 subset of 6. Never used [ 2.199904] iio-core: ******** mask2[8] is 0xffff0000000e2720 [ 2.205660] max1363 1-0064: available_scan_mask 8 subset of 6. Never used [ 2.212458] iio-core: ******** mask2[9] is 0xffff0000000e2660 [ 2.218215] max1363 1-0064: available_scan_mask 9 subset of 6. Never used [ 2.225012] iio-core: ******** mask2[10] is 0xffff0000000e25a0 [ 2.230855] max1363 1-0064: available_scan_mask 10 subset of 6. Never used [ 2.237740] iio-core: ******** mask2[11] is 0xffff0000000e24e0 [ 2.243583] max1363 1-0064: available_scan_mask 11 subset of 6. Never used [ 2.250470] iio-core: ******** mask2[12] is 0xffff0000000e2420 [ 2.256313] max1363 1-0064: available_scan_mask 12 subset of 6. Never used [ 2.263198] iio-core: ******** mask2[13] is 0xffff0000000e2360 [ 2.269041] max1363 1-0064: available_scan_mask 13 subset of 6. Never used [ 2.275926] iio-core: ******** mask1[7] is 0x0 [ 2.280379] iio-core: ******** mask2[8] is 0xffff0000000e2720 [ 2.286135] max1363 1-0064: available_scan_mask 8 subset of 7. Never used [ 2.292934] iio-core: ******** mask2[9] is 0xffff0000000e2660 [ 2.298689] max1363 1-0064: available_scan_mask 9 subset of 7. Never used [ 2.305488] iio-core: ******** mask2[10] is 0xffff0000000e25a0 [ 2.311336] max1363 1-0064: available_scan_mask 10 subset of 7. Never used [ 2.318221] iio-core: ******** mask2[11] is 0xffff0000000e24e0 [ 2.324065] max1363 1-0064: available_scan_mask 11 subset of 7. Never used [ 2.330949] iio-core: ******** mask2[12] is 0xffff0000000e2420 [ 2.336792] max1363 1-0064: available_scan_mask 12 subset of 7. Never used [ 2.343677] iio-core: ******** mask2[13] is 0xffff0000000e2360 [ 2.349520] max1363 1-0064: available_scan_mask 13 subset of 7. Never used [ 2.356406] iio-core: ******** mask1[8] is 0xffff0000000e2720 [ 2.362162] iio-core: ******** mask2[9] is 0xffff0000000e2660 [ 2.367918] max1363 1-0064: available_scan_mask 9 subset of 8. Never used [ 2.374716] iio-core: ******** mask2[10] is 0xffff0000000e25a0 [ 2.380559] max1363 1-0064: available_scan_mask 10 subset of 8. Never used [ 2.387444] iio-core: ******** mask2[11] is 0xffff0000000e24e0 [ 2.393287] max1363 1-0064: available_scan_mask 11 subset of 8. Never used [ 2.400172] iio-core: ******** mask2[12] is 0xffff0000000e2420 [ 2.406015] max1363 1-0064: available_scan_mask 12 subset of 8. Never used [ 2.412901] iio-core: ******** mask2[13] is 0xffff0000000e2360 [ 2.418744] max1363 1-0064: available_scan_mask 13 subset of 8. Never used [ 2.425629] iio-core: ******** mask1[9] is 0xffff0000000e2660 [ 2.431384] iio-core: ******** mask2[10] is 0xffff0000000e25a0 [ 2.437231] max1363 1-0064: available_scan_mask 10 subset of 9. Never used [ 2.444117] iio-core: ******** mask2[11] is 0xffff0000000e24e0 [ 2.449961] max1363 1-0064: available_scan_mask 11 subset of 9. Never used [ 2.456846] iio-core: ******** mask2[12] is 0xffff0000000e2420 [ 2.462689] max1363 1-0064: available_scan_mask 12 subset of 9. Never used [ 2.469575] iio-core: ******** mask2[13] is 0xffff0000000e2360 [ 2.475417] max1363 1-0064: available_scan_mask 13 subset of 9. Never used [ 2.482303] iio-core: ******** mask1[10] is 0xffff0000000e25a0 [ 2.488145] iio-core: ******** mask2[11] is 0xffff0000000e24e0 [ 2.493988] max1363 1-0064: available_scan_mask 11 subset of 10. Never used [ 2.500957] iio-core: ******** mask2[12] is 0xffff0000000e2420 [ 2.506800] max1363 1-0064: available_scan_mask 12 subset of 10. Never used [ 2.513772] iio-core: ******** mask2[13] is 0xffff0000000e2360 [ 2.519615] max1363 1-0064: available_scan_mask 13 subset of 10. Never used [ 2.526587] iio-core: ******** mask1[11] is 0xffff0000000e24e0 [ 2.532429] iio-core: ******** mask2[12] is 0xffff0000000e2420 [ 2.538272] max1363 1-0064: available_scan_mask 12 subset of 11. Never used [ 2.545244] iio-core: ******** mask2[13] is 0xffff0000000e2360 [ 2.551087] max1363 1-0064: available_scan_mask 13 subset of 11. Never used [ 2.558060] iio-core: ******** mask1[12] is 0xffff0000000e2420 [ 2.563906] iio-core: ******** mask2[13] is 0xffff0000000e2360 [ 2.569747] max1363 1-0064: available_scan_mask 13 subset of 12. Never used
linux-stable-mirror@lists.linaro.org