From: Tzung-Bi Shih <tzungbi@kernel.org>
To: "Dawid Niedźwiecki" <dawidn@google.com>
Cc: "Benson Leung" <bleung@chromium.org>,
chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org,
chromeos-krk-upstreaming@google.com,
"Łukasz Bartosik" <ukaszb@chromium.org>
Subject: Re: [PATCH] platform/chrome: Add ChromeOS EC USB driver
Date: Thu, 3 Jul 2025 11:37:41 +0000 [thread overview]
Message-ID: <aGZrhe8Ku7eEIRqm@google.com> (raw)
In-Reply-To: <CAJ_BA_BQOQe61r9t9rL=UiOqpHwOoTSbQcZNe=CrCcjMha_YQg@mail.gmail.com>
On Wed, Jul 02, 2025 at 09:43:40AM +0200, Dawid Niedźwiecki wrote:
> > They doesn't look like shortcomings to me. The corresponding destructor
> > callbacks have to be called when a device is removed anyway.
> >
>
> Yes, anything related to USB communication itself has to be freed, but
> freeing the cros_ec_device structure and calling the cros_ec_unregister
> function can crash the system if any of a userland application has the
> original file cros_ec open and tries to send a command. The chardev driver
> is not aware that the device has been removed and will try to access the
> removed structures.
We have seen a similar crash before but I didn't come out with a solution
at that time. Could you please try [3]?
[3]: https://patchwork.kernel.org/project/chrome-platform/cover/20250703113509.2511758-1-tzungbi@kernel.org/
> > Instead, re-using the same inode for the userland interface however
> > *silently* swapping the underlying devices makes less sense to me.
> >
>
> We are sure it is the same EC device, so why do you think accessing the
> same inode makes less sense? It is a case for specific interface, that reboot
> causes reprobing, which is not a case for other interfaces. I believe
> it should be
> transparent for the cros_ec device user, what interface type is used
> e.g. if it is
> SPI, you can reboot the EC device and wait until it responds to a next command,
> but if it is USB, you would need to reopen the cros_ec file after reboot.
Did some experiments and I understand the difference now. It probably depends
on the bus implementation.
1) SCP over RPMSG
# ectool --name=cros_scp reboot_ec
# dmesg
cros-ec-rpmsg 10500000.scp.cros-ec-rpmsg.13.-1: rpmsg send timeout
mtk-scp 10500000.scp: SCP watchdog timeout! 0x0
remoteproc remoteproc0: crash detected in scp: type watchdog
...
cros-ec-rpmsg 10500000.scp.cros-ec-rpmsg.13.-1: Chrome EC device registered
2) FP over SPI
# ectool --name=cros_fp reboot_ec
# dmesg
cros-ec-spi spi-PRP0001:01: EC failed to respond in time
Anyway, I see your point about the EC over USB gets re-probe once it reboots,
sysjumps, crashes, firmware updates, and etc.
Given that:
- The crash you encountered is a common issue for all cros_ec_X drivers.
- I prefer to keep cros_ec_X drivers simple and similar rather than have
something special (e.g. the memorized `struct cros_ec_device` in current
cros_ec_usb) for fixing the crash.
Could you give [3] a try to see if it fixes the crash and also call
cros_ec_register()/cros_ec_unregister() everytime in the probe/disconnect?
> > No, I don't think so. I think all EC-like devices share the same concern
> > regardless of the transport medium (e.g. SCP over RPMSG, ISH over ISHTP).
>
> Yes, you can run a userland program that opens a cros_ec file and constantly
> sends commands e.g. ectool stress, and then manually unbind the ec
> device, but I believe it can cause some crashes/memory leakage. I don't think
> all drivers are adjusted to hot-plugging.
Yes, we have seen a similar crash before. See comment above.
next prev parent reply other threads:[~2025-07-03 11:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-24 11:00 [PATCH] platform/chrome: Add ChromeOS EC USB driver Dawid Niedzwiecki
2025-06-27 7:53 ` Tzung-Bi Shih
2025-06-30 11:59 ` Dawid Niedźwiecki
2025-06-30 12:09 ` [PATCH v2] " Dawid Niedzwiecki
2025-07-01 8:56 ` [PATCH] " Tzung-Bi Shih
2025-07-01 10:29 ` Dawid Niedźwiecki
2025-07-02 3:58 ` Tzung-Bi Shih
2025-07-02 7:43 ` Dawid Niedźwiecki
2025-07-03 11:37 ` Tzung-Bi Shih [this message]
2025-07-04 9:03 ` Dawid Niedźwiecki
2025-07-09 9:16 ` Tzung-Bi Shih
2025-07-11 16:00 ` Dawid Niedźwiecki
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=aGZrhe8Ku7eEIRqm@google.com \
--to=tzungbi@kernel.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=chromeos-krk-upstreaming@google.com \
--cc=dawidn@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ukaszb@chromium.org \
/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