From: Hongxing Xu <xing1989093@163.com>
To: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>,
mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, xing1989093@163.com
Subject: Re: [PATCH 1/2] bus: mhi: host: Add debug port personality switching
Date: Tue, 24 Nov 2026 20:43:18 +0800 [thread overview]
Message-ID: <20261124124319.2316-1-xing1989093@163.com> (raw)
In-Reply-To: <6b3fbc60-34ec-4b7e-bbc7-84a0ec5d496e@oss.qualcomm.com>
Two questions, both pointing into this patch, so answering them together.
> > +What: /sys/bus/mhi/devices/.../debug_ports
>
> Why sysfs and not debugfs?
Because this is not a debugging aid. It is a documented ABI that end
users and provisioning tools drive on a shipped system, and it has to
remain available there.
What userspace gains is the ability to bring up, on demand, a group of
ports that a given firmware product configuration does not enable by
default: the diagnostic interface, and the same applies to the ADB and
AT ports. A single switch that creates or destroys that whole group is
what is needed; poking channels one at a time is not. That is why it is
described alongside the other controller attributes in
Documentation/ABI/stable/sysfs-bus-mhi.
debugfs cannot serve this, for two concrete reasons.
The first is availability. CONFIG_MHI_BUS_DEBUG is a bool with no
default, so it is off in the configurations product kernels ship, and
it is a compile-time switch: with it disabled, debugfs.c is not built
and the calls in mhi_register_controller() resolve to empty stubs. A
user who needs these ports would have to rebuild the kernel to get at
the control, which is not a usable interface.
The second is capability. MHI's debugfs already exposes states, events,
channels and devices, and all of them are read-only listings. There is
no debugfs entry in MHI that can create or destroy an MHI device, so
this is not a choice between two equivalent interfaces.
There is also a security reason to keep these ports off unless they are
wanted. The diagnostic and ADB ports on a WWAN module are a meaningful
attack surface, and a module that does not need them should not be
exposing them. Hiding that decision behind an interface that is absent
on production kernels would defeat the point.
> > + * @debug_ports: Whether the debug port personality is active, ...
> > + * @debug_ports_pending: Latest personality requested from userspace,
> > + * applied by debug_ports_work
> > + * @debug_ports_work: Applies @debug_ports_pending from the ordered
> > + * high priority workqueue, ...
>
> Are these optional?
None of the three can be dropped for this feature to work, though none
of them is populated by a driver either.
debug_ports records the personality that is currently applied. It is
read by mhi_chan_is_available() on every enumeration, which is what
keeps a debug-only channel hidden while the commercial personality is
active, and it backs the sysfs attribute so userspace can read back
what is in effect. It belongs to the controller because the setting
covers the controller as a whole.
debug_ports_pending carries the value userspace has just written. The
create and destroy work cannot run in the store function itself:
channel devices are created and destroyed by the state transitions on
the ordered hiprio_wq, and pm_mutex does not exclude those transitions,
because a transition releases it before calling
device_for_each_child(). So the work has to be queued on that same
ordered workqueue, and by the time it runs it needs somewhere to read
the request from. Keeping it separate from debug_ports also keeps
"requested" and "applied" distinct while a switch is in flight.
debug_ports_work is that work item. It is initialised in
mhi_register_controller() next to the other work items, queued on the
ordered workqueue, and flushed by the store so the write returns only
once the ports exist.
All three are zero-initialised, so a controller that declares no
debug-only channel starts in the commercial personality and behaves
exactly as before. I am happy to say so explicitly in the kernel-doc.
Could I ask what you have in mind here? If the concern is that the docs
should mark driver-populated fields as optional, these are not
driver-populated and I can word it that way. If you would rather this
state lived somewhere other than struct mhi_controller, I would like to
know your preference before reworking it.
Thanks
prev parent reply other threads:[~2026-11-24 12:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 12:23 Hongxing Xu
2026-11-13 12:23 ` [PATCH 2/2] bus: mhi: host: Add debug-only channel config macros Hongxing Xu
2026-11-13 19:05 ` [PATCH 1/2] bus: mhi: host: Add debug port personality switching Jeff Hugo
2026-11-24 12:43 ` Hongxing Xu [this message]
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=20261124124319.2316-1-xing1989093@163.com \
--to=xing1989093@163.com \
--cc=jeff.hugo@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mani@kernel.org \
--cc=mhi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®