lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2af446d3-7834-4a6b-897b-b14c6bccff65@linaro.org>
Date: Mon, 29 Apr 2024 11:38:01 +0200
From: Neil Armstrong <neil.armstrong@...aro.org>
To: Douglas Anderson <dianders@...omium.org>, dri-devel@...ts.freedesktop.org
Cc: Linus Walleij <linus.walleij@...aro.org>,
 lvzhaoxiong@...qin.corp-partner.google.com,
 Jani Nikula <jani.nikula@...ux.intel.com>, Hsin-Yi Wang <hsinyi@...gle.com>,
 Javier Martinez Canillas <javierm@...hat.com>, Joel Selvaraj
 <jo@...amily.in>, Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
 Cong Yang <yangcong5@...qin.corp-partner.google.com>,
 Sam Ravnborg <sam@...nborg.org>, Daniel Vetter <daniel@...ll.ch>,
 David Airlie <airlied@...il.com>,
 Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
 Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 4/8] drm/mipi-dsi: Introduce
 mipi_dsi_*_write_seq_multi()

Hello Mister Anderson,

On 27/04/2024 01:58, Douglas Anderson wrote:
> The current mipi_dsi_*_write_seq() macros are non-intutitive because
> they contain a hidden "return" statement that will return out of the
> _caller_ of the macro. Let's mark them as deprecated and instead
> introduce some new macros that are more intuitive.
> 
> These new macros are less optimal when an error occurs but should
> behave more optimally when there is no error. Specifically these new
> macros cause smaller code to get generated and the code size savings
> (less to fetch from RAM, less cache space used, less RAM used) are
> important. Since the error case isn't something we need to optimize
> for and these new macros are easier to understand and more flexible,
> they should be used.
> 
> After converting to use these new functions, one example shows some
> nice savings while also being easier to understand.
> 
> $ scripts/bloat-o-meter \
>    ...after/panel-novatek-nt36672e.ko \
>    ...ctx/panel-novatek-nt36672e.ko
> add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-988 (-988)
> Function                                     old     new   delta
> nt36672e_1080x2408_60hz_init                6236    5248    -988
> Total: Before=10651, After=9663, chg -9.28%
> 
> Signed-off-by: Douglas Anderson <dianders@...omium.org>
> ---
> Right now this patch introduces two new functions in
> drm_mipi_dsi.c. Alternatively we could have changed the prototype of
> the "chatty" functions and made the deprecated macros adapt to the new
> prototype. While this sounds nice, it bloated callers of the
> deprecated functioin a bit because it caused the compiler to emit less
> optimal code. It doesn't seem terrible to add two more functions, so I
> went that way.
> 
> Changes in v2:
> - New
> 
>   drivers/gpu/drm/drm_mipi_dsi.c | 56 +++++++++++++++++++++++++++++++++
>   include/drm/drm_mipi_dsi.h     | 57 ++++++++++++++++++++++++++++++++++
>   2 files changed, 113 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> index 1e062eda3b88..b7c75a4396e6 100644
> --- a/drivers/gpu/drm/drm_mipi_dsi.c
> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> @@ -792,6 +792,34 @@ int mipi_dsi_generic_write_chatty(struct mipi_dsi_device *dsi,
>   }
>   EXPORT_SYMBOL(mipi_dsi_generic_write_chatty);
>   

<snip>

>   };
>   
> +/**
> + * struct mipi_dsi_multi_context - Context to call multiple MIPI DSI funcs in a row
> + * @dsi: Pointer to the MIPI DSI device
> + * @accum_err: Storage for the accumulated error over the multiple calls. Init
> + *	to 0. If a function encounters an error then the error code will be
> + *	stored here. If you call a function and this points to a non-zero
> + *	value then the function will be a noop. This allows calling a function
> + *	many times in a row and just checking the error at the end to see if
> + *	any of them failed.
> + */
> +
> +struct mipi_dsi_multi_context {
> +	struct mipi_dsi_device *dsi;
> +	int accum_err;
> +};

I like the design, but having a context struct seems over-engineered while we could pass
a single int over without encapsulating it with mipi_dsi_multi_context.

void mipi_dsi_dcs_write_buffer_multi(struct mipi_dsi_multi_context *ctx,
				     const void *data, size_t len);
vs
void mipi_dsi_dcs_write_buffer_multi(struct mipi_dsi_device *dsi, int *accum_err,
				     const void *data, size_t len);

is the same, and it avoids having to declare a mipi_dsi_multi_context and set ctx->dsi,
and I'll find it much easier to migrate, just add a &ret and make sure ret is initialized to 0.


<snip>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ