From: Maximilian Luz <luzmaximilian@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Blaž Hrastnik" <blaz@mxxn.io>,
"Dorian Stoll" <dorian.stoll@tmsp.io>
Subject: Re: [RFC PATCH 8/9] surface_aggregator: Add DebugFS interface
Date: Wed, 23 Sep 2020 20:29:19 +0200 [thread overview]
Message-ID: <cfed1f74-653c-565b-ea91-877c4e1f63a0@gmail.com> (raw)
In-Reply-To: <CAK8P3a0=98pzgWwBKddy7BQ9g90ga8JEx=MtADW+aqTe0AVV6w@mail.gmail.com>
On 9/23/20 6:48 PM, Arnd Bergmann wrote:
> Versioned interfaces are basically always a mess, try to avoid them. I'd much
> rather see this done in one of two ways:
>
> a) make it a proper documented interface, in this case probably a misc
> character device, and then maintain the interface forever, without
> breaking compatibility with existing users.
>
> b) keep it as a debugfs file, but don't even pretend for it
> to be a documented interface. Anything using it should know
> what they are doing and have a matching user space.
I'll drop the version. I'd still very much like to keep the
documentation as well as keeping this a debugfs file. I hope that I've
made it clear enough in the documentation that it's not intended for use
by anything other than debugging, reverse-engineering, prototyping and
the likes. Especially as having that in debugfs should IMHO give the
impression: "If you rely on it and it breaks, it's not my fault", which
is very much what I want to stick by for now.
Thus I'm not really in favor of making it a "public" device, at least
not yet. This may make sense in case we ever have a concrete need for
user space applications communicating with the EC directly, although I'd
like to structure and commit to that interface once there is such.
>> +/**
>> + * struct ssam_debug_request - Controller request IOCTL argument.
>> + * @target_category: Target category of the SAM request.
>> + * @target_id: Target ID of the SAM request.
>> + * @command_id: Command ID of the SAM request.
>> + * @instance_id: Instance ID of the SAM request.
>> + * @flags: SAM Request flags.
>> + * @status: Request status (output).
>> + * @payload: Request payload (input data).
>> + * @payload.data: Pointer to request payload data.
>> + * @payload.length: Length of request payload data (in bytes).
>> + * @response: Request response (output data).
>> + * @response.data: Pointer to response buffer.
>> + * @response.length: On input: Capacity of response buffer (in bytes).
>> + * On output: Length of request response (number of bytes
>> + * in the buffer that are actually used).
>> + */
>> +struct ssam_dbg_request {
>> + __u8 target_category;
>> + __u8 target_id;
>> + __u8 command_id;
>> + __u8 instance_id;
>> + __u16 flags;
>> + __s16 status;
>> +
>> + struct {
>> + const __u8 __user *data;
>> + __u16 length;
>> + __u8 __pad[6];
>> + } payload;
>> +
>> + struct {
>> + __u8 __user *data;
>> + __u16 length;
>> + __u8 __pad[6];
>> + } response;
>> +};
>
> Binary interfaces are hard. In this case the indirect pointers mean that
> 32-bit user space has an incompatible layout, which you should not do.
>
> Also, having an ioctl on a debugfs file is a bit odd. I wonder if you
> could have this as a transactional file that performs only read/write
> commands, i.e. you pass in a
>
> struct ssam_dbg_request {
> __u8 target_category;
> __u8 target_id;
> __u8 command_id;
> __u8 instance_id;
> __u16 flags;
> __u8 payload[]; /* variable-length */
> };
>
> and you get out a
>
> struct ssam_dbg_response {
> __s16 status;
> __u8 payload[];
> };
>
> and keep the rest unchanged. See fs/libfs.c for how this could be done
> with simple_transaction files.
Thanks! Is there a way to make this compatible with a 32-bit user space?
From a quick search, compat_ptr and compat_uptr_t would be the right way
to transfer pointer?
I've already laid out my main two rationales for using an IOCTL in the
reply to Greg, but here's an overview: First, IOCTLs allow me to execute
requests in parallel with only a single open file descriptor, and
without having to care about allocating buffers for the responses and
waiting until the buffer is read (yes, arguably I still have to manage
buffers, but only in the IOCTL function which I consider a bit more
manageable). I was previously unaware of the simple_transaction helpers
though, so thanks for that pointer! Second, I can easily expand that
interface to handle events sent by the EC, by having the user space
application read from that file. Although that could be moved to a
second file. I just felt having that option of keeping in one would
eventually result in a cleaner interface.
Thanks,
Max
next prev parent reply other threads:[~2020-09-23 18:29 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-23 15:15 [RFC PATCH 0/9] Add support for Microsoft Surface System Aggregator Module Maximilian Luz
2020-09-23 15:15 ` [RFC PATCH 1/9] misc: Add Surface Aggregator subsystem Maximilian Luz
2020-09-23 16:57 ` Greg Kroah-Hartman
2020-09-23 20:34 ` Maximilian Luz
2020-09-24 6:48 ` Greg Kroah-Hartman
2020-09-24 18:16 ` Maximilian Luz
2020-09-23 15:15 ` [RFC PATCH 2/9] surface_aggregator: Add control packet allocation chaching Maximilian Luz
2020-09-23 15:15 ` [RFC PATCH 3/9] surface_aggregator: Add event item " Maximilian Luz
2020-09-23 15:15 ` [RFC PATCH 4/9] surface_aggregator: Add trace points Maximilian Luz
2020-09-23 20:07 ` Steven Rostedt
2020-09-23 23:43 ` Maximilian Luz
2020-09-23 15:15 ` [RFC PATCH 5/9] surface_aggregator: Add error injection capabilities Maximilian Luz
2020-09-23 17:45 ` Greg Kroah-Hartman
2020-09-23 21:28 ` Maximilian Luz
2020-09-23 15:15 ` [RFC PATCH 6/9] surface_aggregator: Add dedicated bus and device type Maximilian Luz
2020-09-23 17:33 ` Greg Kroah-Hartman
2020-09-23 21:12 ` Maximilian Luz
2020-09-24 7:12 ` Greg Kroah-Hartman
2020-09-24 18:15 ` Maximilian Luz
2020-09-23 15:15 ` [RFC PATCH 7/9] docs: driver-api: Add Surface Aggregator subsystem documentation Maximilian Luz
2020-09-23 15:15 ` [RFC PATCH 8/9] surface_aggregator: Add DebugFS interface Maximilian Luz
2020-09-23 16:14 ` Greg Kroah-Hartman
2020-09-23 18:03 ` Maximilian Luz
2020-09-23 18:29 ` Greg Kroah-Hartman
2020-09-23 22:06 ` Maximilian Luz
2020-09-24 6:46 ` Greg Kroah-Hartman
2020-09-24 18:40 ` Maximilian Luz
2020-09-23 16:48 ` Arnd Bergmann
2020-09-23 18:29 ` Maximilian Luz [this message]
2020-09-23 18:51 ` Arnd Bergmann
2020-09-23 22:23 ` Maximilian Luz
2020-09-24 7:41 ` Arnd Bergmann
2020-09-24 18:44 ` Maximilian Luz
2020-09-23 15:15 ` [RFC PATCH 9/9] surface_aggregator: Add Surface ACPI Notify client driver Maximilian Luz
2020-09-23 15:30 ` [RFC PATCH 0/9] Add support for Microsoft Surface System Aggregator Module Arnd Bergmann
2020-09-23 15:43 ` Maximilian Luz
2020-09-23 19:43 ` Arnd Bergmann
2020-09-23 23:28 ` Maximilian Luz
2020-09-24 8:26 ` Arnd Bergmann
2020-09-24 18:59 ` Maximilian Luz
2020-09-24 19:38 ` Arnd Bergmann
2020-09-24 21:07 ` Maximilian Luz
2020-09-25 14:53 ` Andy Shevchenko
2020-09-24 8:30 ` Andy Shevchenko
2020-09-24 19:17 ` Maximilian Luz
2020-09-25 14:58 ` Andy Shevchenko
2020-09-25 15:41 ` Maximilian Luz
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=cfed1f74-653c-565b-ea91-877c4e1f63a0@gmail.com \
--to=luzmaximilian@gmail.com \
--cc=arnd@arndb.de \
--cc=blaz@mxxn.io \
--cc=dorian.stoll@tmsp.io \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.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