All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Pooyan Azad <pooyan.azadparvar@gmail.com>
Cc: Uwe Kleine-König <u.kleine-koenig@baylibre.com>,
	Muhammad Bilal <meatuni001@gmail.com>,
	Herlangga Maulani <w1zardsec@proton.me>,
	Rob Herring <robh@kernel.org>,
	Jeffrey Lin <jeffrey.lin@rad-ic.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 0/3] Input: raydium_i2c_ts report handling fixes
Date: Mon, 23 Nov 2026 20:49:31 -0800	[thread overview]
Message-ID: <3e575d6e2eb90d4a3707319d37134c1a@gmail.com> (raw)
In-Reply-To: <cover.1790612085.git.pooyan.azadparvar@gmail.com>

Hi Pooyan,

On Mon, Sep 28, 2026 at 06:26:15PM +0200, Pooyan Azad wrote:
...
> Patch 2 resizes an existing report buffer when a firmware update changes the
> packet size. Patch 3 moves the initial allocation to the main firmware query
> so devices can remain usable for recovery when they probe in bootloader mode.

There is a teardown ordering issue with using devm_krealloc() in patches 2
and 3.

When a device probes in bootloader mode, ts->report_data has no devres
entry before devm_request_threaded_irq() is called: in patch 2,
devm_kmalloc() with size 0 returns ZERO_SIZE_PTR without calling
devres_add(), and in patch 3, ts->report_data is NULL. When a later
firmware update transitions the controller to main mode and runs
raydium_i2c_query_ts_info(), devm_krealloc() takes its ZERO_OR_NULL_PTR()
fallback to devm_kmalloc() and appends the buffer to the devres list after
the IRQ. On driver unbind, devres releases resources in reverse order,
freeing ts->report_data before free_irq() runs while raydium_i2c_irq() can
still execute.

I do not think we need dynamic allocation for the report buffer at all.
Since pkg_size is a u8 (at most 255 bytes) and raydium_i2c_read() uses
ordinary i2c_transfer() rather than DMA-safe buffers, we can simply embed
"u8 report_data[U8_MAX];" in struct raydium_data. That eliminates the
separate devres allocation, avoids -ENOMEM during firmware updates and
ZERO_SIZE_PTR/NULL handling in bootloader mode, and guarantees the buffer
outlives the IRQ. Patches 2 and 3 then collapse into a single patch
keeping local staging of info/report parameters in
raydium_i2c_query_ts_info() and switching report_data to a fixed-size
array.

While looking at bootloader recovery, note that raydium_i2c_fw_update()
also unconditionally sets ts->boot_mode = RAYDIUM_TS_MAIN even if
raydium_i2c_initialize() returns 0 after seeing RAYDIUM_TS_BLDR, which
can leave contact_size at 0 after a bootloader-mode probe.

Thanks.

-- 
Dmitry

  parent reply	other threads:[~2026-11-24  4:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-27 11:44 [PATCH] Input: raydium_i2c_ts - validate report parameters Pooyan Azad
2026-09-27 17:30 ` Muhammad Bilal
2026-09-27 17:58   ` Pooyan Azadparvar
2026-09-28  2:38 ` Dmitry Torokhov
2026-09-28  6:04   ` Pooyan Azadparvar
2026-09-28 16:26 ` [PATCH v2 0/3] Input: raydium_i2c_ts report handling fixes Pooyan Azad
2026-09-28 16:26   ` [PATCH v2 1/3] Input: raydium_i2c_ts - validate report parameters Pooyan Azad
2026-11-24  4:42     ` Dmitry Torokhov
2026-11-24  7:31       ` Pooyan Azadparvar
2026-09-28 16:26   ` [PATCH v2 2/3] Input: raydium_i2c_ts - resize report buffer after firmware update Pooyan Azad
2026-09-28 16:26   ` [PATCH v2 3/3] Input: raydium_i2c_ts - defer report buffer allocation Pooyan Azad
2026-10-07  9:04   ` [PATCH v2 0/3] Input: raydium_i2c_ts report handling fixes Pooyan Azadparvar
2026-11-04 13:43     ` Pooyan Azadparvar
2026-11-24  4:49   ` Dmitry Torokhov [this message]
2026-11-24 20:40     ` [PATCH v3] Input: raydium_i2c_ts - use a fixed-size report buffer Pooyan Azad

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=3e575d6e2eb90d4a3707319d37134c1a@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=jeffrey.lin@rad-ic.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=meatuni001@gmail.com \
    --cc=pooyan.azadparvar@gmail.com \
    --cc=robh@kernel.org \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=w1zardsec@proton.me \
    /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.