mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "luo.liu.linux" <luo.liu.linux@163.com>
To: "Sakari Ailus" <sakari.ailus@linux.intel.com>
Cc: mchehab@kernel.org, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re:Re: Re: [PATCH] media:v4l2-async:debugfs for registered subdevices
Date: Fri, 13 Mar 2026 21:50:56 +0800 (CST)	[thread overview]
Message-ID: <384d2274.9b3e.19ce776ec2c.Coremail.luo.liu.linux@163.com> (raw)
In-Reply-To: <abP4Mr_s8JRpQH0B@kekkonen.localdomain>


Hi Sakari,

    Apologies if my previous explanation wasn't clear enough. 

    To clarify, the primary goal of this interface is not merely to verify if insmod/rmmod succeeds, 
but to validate the correctness of the asynchronous subdevice registration and unregistration paths,
specifically ensuring that resource allocation and reclamation are handled properly.

   I would like to share a real-world scenario that motivated this patch:

   We had a camera subsystem pipeline like sensor -> dphy -> mipi-csi2 -> isp
subdevice driver that appeared to function perfectly for six months. insmod and rmmod completed without any errors,
and the system seemed stable during normal operation. However, just before a major release, a QA engineer performed 
stress testing involving rapid, repeated cycles of insmod and rmmod, which eventually triggered a kernel crash.

During the debugging process, I inspected the internal global lists:

static LIST_HEAD(subdev_list);
static LIST_HEAD(notifier_list);

By dumping the subdev_list via this debugfs interface, I discovered that a D-PHY subdevice entry remained in the list even 
after its driver was unloaded. Crucially, the output explicitly showed the device name, allowing me to immediately pinpoint
the D-PHY driver as the culprit, rather than blindly troubleshooting other components in the pipeline (such as the sensor or ISP).

This was the critical clue that led me to the root cause: 

The D-PHY subdriver's remove function was missing a call to v4l2_async_cleanup(sd). Consequently, the subdevice was never properly 
unregistered from the async framework, leading to a use-after-free or stale pointer issue during the stress test.

Without this debugfs interface, detecting such "silent" registration leaks is extremely difficult. 
The driver loads and unloads without reporting errors, and standard logs (dmesg) often provide
no indication that an entry was left behind in the core framework's list until a crash occurs under specific timing conditions.


Given this experience, I believe this interface provides a vital visibility point for engineers to:

1,Verify that subdevices are correctly removed from the global list upon driver unload.
2,Catch missing cleanup calls (like v4l2_async_cleanup) early in the development cycle, rather than discovering them through random crashes in stress testing.


I hope this context clarifies why I consider this debugfs interface meaningful and necessary for robust driver development.

Best regards,
Luo


















At 2026-03-13 19:42:42, "Sakari Ailus" <sakari.ailus@linux.intel.com> wrote:
>Hi Luo,
>
>On Fri, Mar 13, 2026 at 07:21:42PM +0800, luo.liu.linux wrote:
>> 
>> Hi Sakari,
>> 
>>     Thank you very much for your reply.
>> 
>>      When building a pipeline in the camera subsystem via Media Entities
>>  
>> (e.g., Sensor -> DPHY -> MIPI-CSI2 -> ISP), it is crucial to verify that the registration
>> 
>>  and unregistration processes for each sub-device (subdev) driver within the pipeline 
>> 
>> are functioning correctly.
>
>You don't need a debugfs interface for that, do you? We have a large number
>of things that can go wrong that are much more complicated than this (and
>there's no debugfs interface to verify those either, no, largely because it
>wouldn't be meaningful).
>
>-- 
>Regards,
>
>Sakari Ailus

  reply	other threads:[~2026-03-13 13:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13  7:58 luo.liu
2026-03-13 10:28 ` Sakari Ailus
2026-03-13 11:21   ` luo.liu.linux
2026-03-13 11:42     ` Sakari Ailus
2026-03-13 13:50       ` luo.liu.linux [this message]
2026-03-16 16:48         ` Sakari Ailus
2026-03-17  3:37           ` luo.liu.linux
2026-03-17  8:21             ` Sakari Ailus
2026-03-17 11:14               ` luo.liu.linux
2026-03-19 20:30                 ` Laurent Pinchart
2026-03-20  6:52                   ` luo.liu.linux

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=384d2274.9b3e.19ce776ec2c.Coremail.luo.liu.linux@163.com \
    --to=luo.liu.linux@163.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.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

Powered by JetHome