From: "Nicolás Antinori" <nico.antinori.7@gmail.com>
To: <sashiko-reviews@lists.linux.dev>
Cc: <devicetree@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
<robh@kernel.org>, <conor+dt@kernel.org>
Subject: Re: [PATCH v6 2/3] drm/ch1115: add support for Chipwealth CH1115 OLED controller
Date: Thu, 05 Nov 2026 16:12:31 -0300 [thread overview]
Message-ID: <DMNIL4ZYZWLZ.3K6BK08P4SUD5@gmail.com> (raw)
In-Reply-To: <sashiko-outbox-196034@kernel.org>
Hello,
On Tue Nov 3, 2026 at 6:05 PM -03, sashiko-bot wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [Medium] drm/ch1115: out-of-range display offset 64 sent in ch1115_oled_init()
> - [Medium] drm/ch1115: missing DC-DC disable in ch1115_encoder_atomic_disable()
> --
>
> commit e5268b4f2a7c534421925bdee0145caf63c50632
> Author: Nicolás Antinori <nico.antinori.7@gmail.com>
>
> drm/ch1115: add support for Chipwealth CH1115 OLED controller
>
> This commit adds a DRM driver for Chipwealth CH1115 monochrome dot matrix
> OLED panels connected over I2C.
>
>> diff --git a/drivers/gpu/drm/tiny/ch1115-i2c.c b/drivers/gpu/drm/tiny/ch1115-i2c.c
>> new file mode 100644
>> index 0000000000000..08fee5a09f4f9
>> --- /dev/null
>> +++ b/drivers/gpu/drm/tiny/ch1115-i2c.c
>> @@ -0,0 +1,859 @@
>
> [ ... ]
>
>> +static int ch1115_oled_init(struct ch1115_device *ch1115)
>> +{
>> + u8 commands[] = {
>> + CH1115_CMD_OFF,
>> +
>> + CH1115_CMD_CLOCK_DIVIDE_RATIO,
>> + CH1115_VAL_CLOCK_DIVIDE_RATIO(CH1115_VAL_CLOCK_OSC_FREQ,
>> + CH1115_VAL_CLOCK_DIV_RATIO),
>> +
>> + CH1115_CMD_MUX_RATIO,
>> + ch1115->height - 1,
>> +
>> + CH1115_CMD_OFFSET,
>> + ch1115->flip_vertical
>> + ? ch1115->y_start_offset
>> + : CH1115_MAX_HEIGHT - ch1115->y_start_offset,
>
> [Severity: Medium]
> Does ch1115_oled_init() send an out-of-range value for CH1115_CMD_OFFSET when
> flip_vertical is false and y_start_offset is 0?
>
> In ch1115_parse_dt(), y_start_offset defaults to 0 when the chipwealth,offset
> property is omitted, and is otherwise restricted to [0, CH1115_MAX_HEIGHT - 1]
> (0 to 63):
>
> ret = of_property_read_u32(np, "chipwealth,offset", &val);
> if (ret) {
> ch1115->y_start_offset = 0;
> } else {
> if (val > CH1115_MAX_HEIGHT - 1) {
> dev_err(dev, "chipwealth,offset=%d must be [0-%d]\n",
> val, CH1115_MAX_HEIGHT - 1);
> return -EINVAL;
> }
> ch1115->y_start_offset = (u8)val;
> }
>
> When ch1115_encoder_atomic_enable() calls ch1115_oled_init() with
> flip_vertical set to false and y_start_offset set to 0, the expression
> CH1115_MAX_HEIGHT - ch1115->y_start_offset evaluates to 64 (0x40), which
> overflows the 6-bit [0, 63] vertical offset field instead of wrapping modulo
> CH1115_MAX_HEIGHT to 0.
This is a false positive, the datasheet [1] states that the formula for
this command (D3) is 64 - n, where n is a 6 bit number in the range [0,
63]. I did not use a mask for this because the unused bits get ignored.
>
> [ ... ]
>
>> +static void ch1115_encoder_atomic_enable(struct drm_encoder *encoder,
>> + struct drm_atomic_commit *state)
>> +{
>> + struct drm_device *drm = encoder->dev;
>> + struct ch1115_device *ch1115 = drm_to_ch1115(drm);
>> + int ret;
>> +
>> + ret = ch1115_oled_init(ch1115);
>> + if (ret < 0)
>> + return;
>> +
>> + u8 command = CH1115_CMD_ON;
>> +
>> + ret = ch1115_send_command_list(ch1115, &command, 1);
>> + if (ret < 0)
>> + return;
>> +
>> + backlight_enable(ch1115->bl_dev);
>> +}
>> +
>> +static void ch1115_encoder_atomic_disable(struct drm_encoder *encoder,
>> + struct drm_atomic_commit *state)
>> +{
>> + struct drm_device *drm = encoder->dev;
>> + struct ch1115_device *ch1115 = drm_to_ch1115(drm);
>> +
>> + backlight_disable(ch1115->bl_dev);
>> +
>> + u8 command = CH1115_CMD_OFF;
>> +
>> + ch1115_send_command_list(ch1115, &command, 1);
>> +}
>
> [Severity: Medium]
> Should ch1115_encoder_atomic_disable() also disable the internal DC-DC
> converter?
>
> When the encoder is enabled, ch1115_encoder_atomic_enable() calls
> ch1115_oled_init(), which turns on the DC-DC converter with CH1115_CMD_DC_DC
> and CH1115_VAL_DC_DC_ON. However, when the display is disabled via KMS or
> during system shutdown via ch1115_shutdown() -> drm_atomic_helper_shutdown(),
> ch1115_encoder_atomic_disable() only sends CH1115_CMD_OFF, leaving the DC-DC
> converter enabled.
>
> By contrast, ch1115_remove() explicitly sends CH1115_CMD_OFF,
> CH1115_CMD_DC_DC, and CH1115_VAL_DC_DC_OFF after calling
> drm_atomic_helper_shutdown():
>
> u8 cmd_list[] = {
> CH1115_CMD_OFF,
> CH1115_CMD_DC_DC,
> CH1115_VAL_DC_DC_OFF,
> };
>
> drm_dev_unplug(&ch1115->dev);
> drm_atomic_helper_shutdown(&ch1115->dev);
>
> ch1115_send_command_list(ch1115, cmd_list, ARRAY_SIZE(cmd_list));
>
> If ch1115_encoder_atomic_disable() sent CH1115_CMD_OFF, CH1115_CMD_DC_DC, and
> CH1115_VAL_DC_DC_OFF, wouldn't that properly power down the DC-DC converter on
> both KMS disable and ch1115_shutdown(), while avoiding the duplicate command
> sequence in ch1115_remove()?
I believe this is accurate, apologies for this oversight. I have a local
version of this fixed, tested with modetest, unloading the module,
rebooting and power off the system entirely. I'll send a v7 in a few
days in case there is a review.
Best regards,
Nicolás
[1] https://datasheet4u.com/download/1576606/CH1115.html
next prev parent reply other threads:[~2026-11-05 19:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 20:46 [PATCH v6 0/3] Add support for CH1115 Controller Nicolás Antinori
2026-11-03 20:46 ` [PATCH v6 1/3] dt-bindings: display: add Chipwealth CH1115 OLED Controller Nicolás Antinori
2026-11-03 20:46 ` [PATCH v6 2/3] drm/ch1115: add support for Chipwealth CH1115 OLED controller Nicolás Antinori
2026-11-03 21:05 ` sashiko-bot
2026-11-05 19:12 ` Nicolás Antinori [this message]
2026-11-03 20:46 ` [PATCH v6 3/3] MAINTAINERS: add entry for Chipwealth CH1115 OLED Controller Nicolás Antinori
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=DMNIL4ZYZWLZ.3K6BK08P4SUD5@gmail.com \
--to=nico.antinori.7@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.