From: "andriy.shevchenko@linux.intel.com" <andriy.shevchenko@linux.intel.com>
To: Aditya Garg <gargaditya08@live.com>
Cc: "pmladek@suse.com" <pmladek@suse.com>,
Steven Rostedt <rostedt@goodmis.org>,
"linux@rasmusvillemoes.dk" <linux@rasmusvillemoes.dk>,
"senozhatsky@chromium.org" <senozhatsky@chromium.org>,
Jonathan Corbet <corbet@lwn.net>,
"maarten.lankhorst@linux.intel.com"
<maarten.lankhorst@linux.intel.com>,
"mripard@kernel.org" <mripard@kernel.org>,
"tzimmermann@suse.de" <tzimmermann@suse.de>,
"airlied@gmail.com" <airlied@gmail.com>,
"simona@ffwll.ch" <simona@ffwll.ch>,
Andrew Morton <akpm@linux-foundation.org>,
"apw@canonical.com" <apw@canonical.com>,
"joe@perches.com" <joe@perches.com>,
"dwaipayanray1@gmail.com" <dwaipayanray1@gmail.com>,
"lukas.bulwahn@gmail.com" <lukas.bulwahn@gmail.com>,
"sumit.semwal@linaro.org" <sumit.semwal@linaro.org>,
"christian.koenig@amd.com" <christian.koenig@amd.com>,
Kerem Karabay <kekrby@gmail.com>,
Aun-Ali Zaidi <admin@kodeit.net>,
Orlando Chamberlain <orlandoch.dev@gmail.com>,
Atharva Tiwari <evepolonium@gmail.com>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
"linaro-mm-sig@lists.linaro.org" <linaro-mm-sig@lists.linaro.org>,
Hector Martin <marcan@marcan.st>,
"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
Asahi Linux Mailing List <asahi@lists.linux.dev>,
Sven Peter <sven@svenpeter.dev>, Janne Grunau <j@jannau.net>
Subject: Re: [PATCH v3 3/3] drm/tiny: add driver for Apple Touch Bars in x86 Macs
Date: Fri, 21 Feb 2025 22:42:33 +0200 [thread overview]
Message-ID: <Z7jlORk0MiMFTmp6@smile.fi.intel.com> (raw)
In-Reply-To: <A373EDB5-528D-4ECF-8CF3-4F96DE6E3797@live.com>
On Fri, Feb 21, 2025 at 07:13:06PM +0000, Aditya Garg wrote:
> > On Fri, Feb 21, 2025 at 11:37:57AM +0000, Aditya Garg wrote:
...
> >> +} __packed;
> >
> > Why __packed? Please explain and justify for all the data types that are marked
> > with this attribute.
>
> Just following the original Windows driver here (#pragma pack) :
>
> https://github.com/imbushuo/DFRDisplayKm/blob/master/src/DFRDisplayKm/include/DFRHostIo.h
>
> IMO these structures are used for communication with the Touch Bar over USB.
> The hardware expects a very specific layout for the data it receives and
> sends. If the compiler were to insert padding for alignment, it would break
> the communication protocol because the fields would not be in the expected
> positions.
What padding, please? Why TCP UAPI headers do not have these attributes?
Think about it, and think about what actually __packed does and how it affects
(badly) the code generation. Otherwise it looks like a cargo cult.
> I tried removing __packed btw and driver no longer works.
So, you need to find a justification why. But definitely not due to padding in
many of them. They can go without __packed as they are naturally aligned.
...
> >> + if (response->msg == APPLETBDRM_MSG_SIGNAL_READINESS) {
> >> + if (!readiness_signal_received) {
> >> + readiness_signal_received = true;
> >> + goto retry;
> >> + }
> >> +
> >> + drm_err(drm, "Encountered unexpected readiness signal\n");
> >> + return -EIO;
> >> + }
> >> +
> >> + if (actual_size != size) {
> >> + drm_err(drm, "Actual size (%d) doesn't match expected size (%lu)\n",
> >> + actual_size, size);
> >> + return -EIO;
> >> + }
> >> +
> >> + if (response->msg != expected_response) {
> >> + drm_err(drm, "Unexpected response from device (expected %p4ch found %p4ch)\n",
> >> + &expected_response, &response->msg);
> >> + return -EIO;
> >
> > For three different cases the same error code, can it be adjusted more to the
> > situation?
>
> All these are I/O errors, you got any suggestion?
Your email client mangled the code so badly that it's hard to read. But I would
suggest to use -EINTR in the first case, and -EBADMSG. But also you may consider
-EPROTO.
> >> + }
...
> >> + if (ret)
> >> + return ret;
> >
> >> + else if (!new_plane_state->visible)
> >
> > Why 'else'? It's redundant.
>
> I’ve just followed what other drm drivers are doing here:
>
> https://elixir.bootlin.com/linux/v6.13.3/source/drivers/gpu/drm/tiny/bochs.c#L436
> https://elixir.bootlin.com/linux/v6.13.3/source/drivers/gpu/drm/tiny/cirrus.c#L363
>
> And plenty more
A bad example is still a bad example. 'else' is simply redundant in this
case and add a noisy to the code.
> I won’t mind removing else. You want that?
Sure.
...
> >> + request_size = ALIGN(sizeof(struct appletbdrm_fb_request) +
> >> + frames_size +
> >> + sizeof(struct appletbdrm_fb_request_footer), 16);
> >
> > Missing header for ALIGN().
> >
> > But have you checked overflow.h for the possibility of using some helper macros
> > from there? This is what should be usually done for k*alloc() in the kernel.
>
> I don’t really think we need a macro here.
Hmm... is frames_size known to be in a guaranteed range to make sure no
potential overflow happens?
> >> + appletbdrm_state->request = kzalloc(request_size, GFP_KERNEL);
> >> +
> >> + if (!appletbdrm_state->request)
> >> + return -ENOMEM;
...
> >> + request->msg_id = timestamp & 0xff;
> >
> > Why ' & 0xff'?
>
> https://github.com/imbushuo/DFRDisplayKm/blob/master/src/DFRDisplayKm/DfrDisplay.c#L147
This is not an answer.
Why do you need this here? Isn't the type of msg_id enough?
...
> >> + adev->mode = (struct drm_display_mode) {
> >
> > Why do you need a compound literal here? Perhaps you want to have that to be
> > done directly in DRM_MODE_INIT()?
>
> I really don’t find this as an issue. You want me to declare another structure, basically this?:
Nope, I'm asking if the DRM_MODE_INIT() is done in a way that it only can be
used for the static data. Seems like the case. Have you tried to convert
DRM_MODE_INIT() to be always a compound literal? Does it break things?
> struct drm_display_mode mode = {
> DRM_MODE_INIT(60, adev->height, adev->width,
> DRM_MODE_RES_MM(adev->height, 218),
> DRM_MODE_RES_MM(adev->width, 218))
> };
> adev->mode = mode;
>
> >> + DRM_MODE_INIT(60, adev->height, adev->width,
> >> + DRM_MODE_RES_MM(adev->height, 218),
> >> + DRM_MODE_RES_MM(adev->width, 218))
> >> + };
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-02-21 20:42 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 11:36 [PATCH v3 1/3] drm/format-helper: Add conversion from XRGB8888 to BGR888 Aditya Garg
2025-02-21 11:37 ` [PATCH v3 2/3] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc Aditya Garg
2025-02-21 11:54 ` Rasmus Villemoes
2025-02-21 15:29 ` andriy.shevchenko
2025-02-21 19:37 ` Aditya Garg
2025-02-21 20:18 ` andriy.shevchenko
2025-02-21 20:22 ` andriy.shevchenko
2025-02-21 11:37 ` [PATCH v3 3/3] drm/tiny: add driver for Apple Touch Bars in x86 Macs Aditya Garg
2025-02-21 15:48 ` andriy.shevchenko
2025-02-21 19:13 ` Aditya Garg
2025-02-21 20:42 ` andriy.shevchenko [this message]
2025-02-22 9:07 ` Aditya Garg
2025-02-22 12:22 ` Aditya Garg
2025-02-23 14:58 ` Aditya Garg
2025-02-24 8:41 ` Thomas Zimmermann
2025-02-24 9:47 ` andriy.shevchenko
2025-02-24 11:20 ` Aditya Garg
2025-02-24 11:42 ` andriy.shevchenko
2025-02-24 11:57 ` Aditya Garg
2025-02-24 12:27 ` andriy.shevchenko
2025-02-24 9:09 ` Thomas Zimmermann
2025-02-24 9:14 ` Aditya Garg
2025-02-21 15:51 ` [PATCH v3 1/3] drm/format-helper: Add conversion from XRGB8888 to BGR888 andriy.shevchenko
2025-02-21 17:21 ` Aditya Garg
2025-02-21 20:25 ` andriy.shevchenko
2025-02-24 9:19 ` Thomas Zimmermann
2025-02-24 9:55 ` andriy.shevchenko
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=Z7jlORk0MiMFTmp6@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=admin@kodeit.net \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=asahi@lists.linux.dev \
--cc=christian.koenig@amd.com \
--cc=corbet@lwn.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=dwaipayanray1@gmail.com \
--cc=evepolonium@gmail.com \
--cc=gargaditya08@live.com \
--cc=j@jannau.net \
--cc=joe@perches.com \
--cc=kekrby@gmail.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linux@rasmusvillemoes.dk \
--cc=lukas.bulwahn@gmail.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=marcan@marcan.st \
--cc=mripard@kernel.org \
--cc=orlandoch.dev@gmail.com \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=simona@ffwll.ch \
--cc=sumit.semwal@linaro.org \
--cc=sven@svenpeter.dev \
--cc=tzimmermann@suse.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.