From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Hermes Wu <Hermes.Wu@ite.com.tw>
Cc: Kenneth Hung <Kenneth.hung@ite.com.tw>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Allen Chen <allen.chen@ite.com.tw>,
"open list:DRM DRIVERS" <dri-devel@lists.freedesktop.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 02/11] drm/bridge: it6505: fix aux operation for edid read
Date: Thu, 26 Sep 2024 10:10:49 +0200 [thread overview]
Message-ID: <16833ec2-d6bf-4d7f-9385-1430277fc047@collabora.com> (raw)
In-Reply-To: <20240926074755.22176-3-Hermes.Wu@ite.com.tw>
Il 26/09/24 09:47, Hermes Wu ha scritto:
> From: Hermes Wu <Hermes.wu@ite.com.tw>
>
> The EDID read operation can reach the maximum size of the AUX FIFO buffer.
>
> Fixes: b5c84a9edcd4 ("drm/bridge: add it6505 driver")
> Signed-off-by: Hermes Wu <Hermes.wu@ite.com.tw>
> ---
> drivers/gpu/drm/bridge/ite-it6505.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> index 28a8043229d3..b451d3c2ac1d 100644
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c
> @@ -1078,8 +1078,11 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *it6505,
> int i, ret_size, ret = 0, request_size;
int fifo_max_sz = (cmd == CMD_AUX_I2C_EDID_READ) ?
AUX_FIFO_MAX_SIZE : 4;
which later becomes
int fifo_max_sz = (cmd == CMD_AUX_I2C_EDID_READ || cmd == CMD_AUX_GET_KSV_LIST) ?
AUX_FIFO_MAX_SIZE : 4;
otherwise you can do it "the long way"...
if (cmd == .....)
fifo_max_sz = AUX_FIFO_MAX_SIZE;
else
fifo_max_sz = 4;
The point is, cmd won't change during iterations, so it's useless to put that if
branch inside of that loop below.
>
> mutex_lock(&it6505->aux_lock);
> - for (i = 0; i < size; i += 4) {
> - request_size = min((int)size - i, 4);
request_size = min_t(int, (int)size - i, fifo_max_sz);
P.S.: Also, I'd consider changing this to a do-while instead...
Cheers,
Angelo
> + for (i = 0; i < size; ) {
> + if (cmd == CMD_AUX_I2C_EDID_READ)
> + request_size = min_t(int, (int)size - i, AUX_FIFO_MAX_SIZE);
> + else
> + request_size = min_t(int, (int)size - i, 4);
> ret_size = it6505_aux_operation(it6505, cmd, address + i,
> buffer + i, request_size,
> reply);
> @@ -1088,6 +1091,7 @@ static ssize_t it6505_aux_do_transfer(struct it6505 *it6505,
> goto aux_op_err;
> }
>
> + i += request_size;
> ret += ret_size;
> }
>
next prev parent reply other threads:[~2024-09-26 8:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-26 7:47 [PATCH v4 00/11] fix HDCP CTS fail items and add MCCS support Hermes Wu
2024-09-26 7:47 ` [PATCH v4 01/11] drm/bridge: it6505: change aux max fifo size Hermes Wu
2024-09-26 7:51 ` Dmitry Baryshkov
2024-09-26 7:47 ` [PATCH v4 02/11] drm/bridge: it6505: fix aux operation for edid read Hermes Wu
2024-09-26 7:53 ` Dmitry Baryshkov
2024-09-26 8:04 ` Hermes.Wu
2024-09-26 8:05 ` Dmitry Baryshkov
2024-09-26 8:10 ` AngeloGioacchino Del Regno [this message]
2024-09-26 7:47 ` [PATCH v4 03/11] drm/bridge: it6505: add aux operation for HDCP ksv list read Hermes Wu
2024-09-26 7:57 ` Dmitry Baryshkov
2024-09-26 9:46 ` Hermes.Wu
2024-09-26 12:17 ` Dmitry Baryshkov
2024-09-26 7:47 ` [PATCH v4 04/11] drm/bridge: it6505: fix aux command write to aux operaction register Hermes Wu
2024-09-26 8:01 ` Dmitry Baryshkov
2024-09-26 8:53 ` Hermes.Wu
2024-09-26 8:10 ` AngeloGioacchino Del Regno
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=16833ec2-d6bf-4d7f-9385-1430277fc047@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=Hermes.Wu@ite.com.tw \
--cc=Kenneth.hung@ite.com.tw \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=allen.chen@ite.com.tw \
--cc=andrzej.hajda@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=rfoss@kernel.org \
--cc=simona@ffwll.ch \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox