From: sashiko-bot@kernel.org
To: "Varshini Rajendran" <varshini.rajendran@microchip.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v6 07/17] iio: adc: at91-sama5d2_adc: adapt the driver for sama7d65
Date: Thu, 06 Aug 2026 09:09:31 +0000 [thread overview]
Message-ID: <20260806090932.5724D1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260806074024.531259-8-varshini.rajendran@microchip.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] The temperature channel on SAMA7D65 (and SAMA7G5) is broken for buffered IIO capture and causes hardware corruption when enabled.
- [High] Channel 0 is incorrectly treated as a touchscreen channel for SAMA7D65 (and SAMA7G5), causing invalid register writes and hardware corruption.
--
--- Patch [7]: [PATCH v6 07/17] iio: adc: at91-sama5d2_adc: adapt the driver for sama7d65 ---
commit d121e4a04e57309a9a2c8f55746f85c0f6a300ed
Author: Varshini Rajendran <varshini.rajendran@microchip.com>
iio: adc: at91-sama5d2_adc: adapt the driver for sama7d65
This commit adds support for the sama7d65 ADC by introducing a new
compatible string and platform data struct. It also updates the Kconfig
help text to mention the SAMA7 SoC family. The main difference highlighted
is the calibration data layout.
> diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
> index 3e9feb824a66f..c1e5139a058ca 100644
> --- a/drivers/iio/adc/at91-sama5d2_adc.c
> +++ b/drivers/iio/adc/at91-sama5d2_adc.c
[ ... ]
> @@ -766,6 +775,24 @@ static const struct at91_adc_platform sama7g5_platform = {
> .temp_calib_layout = &sama7g5_temp_calib,
> };
>
> +static const struct at91_adc_platform sama7d65_platform = {
> + .layout = &sama7g5_layout,
> + .adc_channels = &at91_sama7g5_adc_channels,
> + .nr_channels = AT91_SAMA7G5_SINGLE_CHAN_CNT +
> + AT91_SAMA7G5_DIFF_CHAN_CNT +
> + AT91_SAMA7G5_TEMP_CHAN_CNT,
> + .max_channels = ARRAY_SIZE(at91_sama7g5_adc_channels),
> + .max_index = AT91_SAMA7G5_MAX_CHAN_IDX,
[Severity: High]
This is a pre-existing issue, but it appears to be propagated to the new
sama7d65 SoC. Can this max_index value break buffered IIO capture for the
temperature channel?
The driver sets max_index to 25 (AT91_SAMA7G5_MAX_CHAN_IDX), but the
temperature channel uses scan_index 31.
When a user enables only the temperature channel (scan_index 31),
at91_adc_current_chan_is_touch() checks only up to max_index + 1 (26):
drivers/iio/adc/at91-sama5d2_adc.c:at91_adc_current_chan_is_touch() {
...
return !!bitmap_subset(indio_dev->active_scan_mask,
&st->touch_st.channels_bitmask,
st->soc_info.platform->max_index + 1);
}
Since bit 31 is beyond this size, the first 26 bits of active_scan_mask are 0,
making bitmap_subset() incorrectly return true.
This misidentifies the temperature channel as a touchscreen, invoking
at91_adc_configure_touch() which writes to TSMR (offset 0 on this SoC),
corrupting the ADC Control Register (CR) and breaking the device.
> + .hw_trig_cnt = AT91_SAMA7G5_HW_TRIG_CNT,
> + .osr_mask = GENMASK(18, 16),
> + .oversampling_avail = { 1, 4, 16, 64, 256 },
> + .oversampling_avail_no = 5,
> + .chan_realbits = 16,
> + .temp_sensor = true,
> + .temp_chan = AT91_SAMA7G5_ADC_TEMP_CHANNEL,
> + .temp_calib_layout = &sama7d65_temp_calib,
> +};
[Severity: High]
This isn't a bug introduced by this patch, but the same pattern is copied
here. Could leaving the touch channel fields uninitialized incorrectly treat
ADC channel 0 as a touchscreen?
The sama7d65_platform struct does not initialize touch_chan_x, touch_chan_y,
or touch_chan_p, so they default to 0.
During at91_adc_probe(), bitmap_set() unconditionally sets these bits in the
touchscreen channels_bitmask:
drivers/iio/adc/at91-sama5d2_adc.c:at91_adc_probe() {
...
bitmap_set(&st->touch_st.channels_bitmask,
st->soc_info.platform->touch_chan_x, 1);
...
}
When channel 0 is used for buffered capture, at91_adc_current_chan_is_touch()
incorrectly evaluates to true.
This misconfigures the ADC and causes writes to touchscreen registers which
are undefined for this SoC (evaluating to offset 0x0), corrupting the ADC
Control Register (CR).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260806074024.531259-1-varshini.rajendran@microchip.com?part=7
next prev parent reply other threads:[~2026-08-06 9:09 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 7:40 [PATCH v6 00/17] Add thermal management support for sama7d65 Varshini Rajendran
2026-08-06 7:40 ` [PATCH v6 01/17] dt-bindings: iio: adc: at91-sama5d2: document sama7d65 Varshini Rajendran
2026-08-06 7:40 ` [PATCH v6 02/17] nvmem: add DEFINE_FREE for nvmem_cell_put cleanup Varshini Rajendran
2026-08-06 7:40 ` [PATCH v6 03/17] iio: adc: at91-sama5d2_adc: use cleanup.h for NVMEM buffer Varshini Rajendran
2026-08-06 7:40 ` [PATCH v6 04/17] iio: adc: at91-sama5d2_adc: rework temp calibration layout handling Varshini Rajendran
2026-08-06 9:07 ` sashiko-bot
2026-08-06 7:40 ` [PATCH v6 05/17] iio: adc: at91-sama5d2_adc: add condition to validate calibration data Varshini Rajendran
2026-08-06 7:40 ` [PATCH v6 06/17] iio: adc: at91-sama5d2_adc: remove unnecessary casts in of_device_id Varshini Rajendran
2026-08-06 7:40 ` [PATCH v6 07/17] iio: adc: at91-sama5d2_adc: adapt the driver for sama7d65 Varshini Rajendran
2026-08-06 9:09 ` sashiko-bot [this message]
2026-08-06 7:40 ` [PATCH v6 08/17] dt-bindings: nvmem: microchip,sama7g5-otpc: add sama7d65 and dt node example Varshini Rajendran
2026-08-06 9:07 ` sashiko-bot
2026-08-06 7:40 ` [PATCH v6 09/17] nvmem: microchip-otpc: nvmem: microchip-otpc: add tag-based packet lookup Varshini Rajendran
2026-08-06 9:10 ` sashiko-bot
2026-08-06 7:40 ` [PATCH v6 10/17] nvmem: microchip-otpc: nvmem: add emulation mode and OTP access validation Varshini Rajendran
2026-08-06 9:08 ` sashiko-bot
2026-08-06 7:40 ` [PATCH v6 11/17] ARM: dts: microchip: sama7d65: add cpu opps Varshini Rajendran
2026-08-06 7:40 ` [PATCH v6 12/17] ARM: dts: microchip: sama7d65: Add ADC node Varshini Rajendran
2026-08-06 9:12 ` sashiko-bot
2026-08-06 7:40 ` [PATCH v6 13/17] ARM: dts: microchip: sama7d65_curiosity: Enable ADC, DVFS Varshini Rajendran
2026-08-06 7:40 ` [PATCH v6 14/17] ARM: dts: microchip: sama7d65: add otpc node Varshini Rajendran
2026-08-06 9:23 ` sashiko-bot
2026-08-06 7:40 ` [PATCH v6 15/17] ARM: dts: microchip: sama7d65: add cells for temperature calibration Varshini Rajendran
2026-08-06 9:19 ` sashiko-bot
2026-08-06 7:40 ` [PATCH v6 16/17] ARM: dts: microchip: sama7d65: add temperature sensor Varshini Rajendran
2026-08-06 9:18 ` sashiko-bot
2026-08-06 7:40 ` [PATCH v6 17/17] ARM: dts: microchip: sama7d65: add thermal zones node Varshini Rajendran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260806090932.5724D1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=varshini.rajendran@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox