mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeff Hugo <jeff.hugo@oss.qualcomm.com>
To: Hongxing Xu <xing1989093@163.com>
Cc: Manivannan Sadhasivam <mani@kernel.org>,
	mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] bus: mhi: host: Add debug port personality switching
Date: Tue, 1 Dec 2026 15:06:24 -0700	[thread overview]
Message-ID: <2cc01439-5efd-4c25-bdb9-1accb7f3bb79@oss.qualcomm.com> (raw)
In-Reply-To: <20261124124319.2316-1-xing1989093@163.com>

On 11/24/2026 5:43 AM, Hongxing Xu wrote:
> 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.

How is this not a debugging aid? Your patch subject says "Add debug 
port".  Your commit text mentions a "debug personality" and "debug 
ports" among other uses of "debug".

I'm confused, debug != debugging?

I didn't ask this before, but since you are claiming this is not a 
debugging aid, how does one put the device into this alternate mode? 
Load a signed APDP (Apps Processor Debug Policy) file?  That is a 
debugging flow, and not something that is easily done in an arbitrary 
situation.

> 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.

What product kernels are you referring to?  I use CONFIG_MHI_BUS_DEBUG 
regularly on RHEL and Ubuntu for a variety of device types.

This is starting to look like a niche problem.

> 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.

I don't know how this is an argument.  What you are arguing for does not 
exist in sysfs either.  You are creating it.

> 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.

I thought your argument was that these interfaces are inactive in normal 
mode.  How can they be a security issue?

> 
>>> + * @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.

So every controller must support these?  That's not acceptable to me.

> 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.

You made a mistake, and I initially missed it.

You document these in the controller config struct, but add them to the 
controller struct.  That is not valid.  One of those structures is 
populated by the controller driver, and the other is not.

This will need to be fixed, but I think there are fundamental problems 
with what you are attempting to accomplish here which should be 
addressed before this implementation detail becomes relevant.

-Jeff


      reply	other threads:[~2026-12-01 22:06 UTC|newest]

Thread overview: 5+ 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
2026-12-01 22:06     ` Jeff Hugo [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=2cc01439-5efd-4c25-bdb9-1accb7f3bb79@oss.qualcomm.com \
    --to=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 \
    --cc=xing1989093@163.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

all inboxes | Powered by JetHome®