From: Thomas Zimmermann <tzimmermann@suse.de>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Dave Airlie <airlied@redhat.com>,
Jocelyn Falempe <jfalempe@redhat.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v3] drm/ast: astdp: fix loop timeout check
Date: Mon, 12 Aug 2024 12:43:51 +0200 [thread overview]
Message-ID: <9ab2e0bb-3c9a-4197-ab73-e0cc82c3efb6@suse.de> (raw)
In-Reply-To: <1ba8da25-2d09-4924-a4ff-c0714bfbb192@stanley.mountain>
Hi
Am 12.08.24 um 10:29 schrieb Dan Carpenter:
> This code has an issue because it loops until "i" is set to UINT_MAX but
> the test for failure assumes that "i" is set to zero. The result is that
> it will only print an error message if we succeed on the very last try.
> Reformat the loop to count forwards instead of backwards.
>
> Fixes: 2281475168d2 ("drm/ast: astdp: Perform link training during atomic_enable")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Thanks a lot for the fix. I'll merge it during the week if no other
comments come in.
Best regards
Thomas
> ---
> v3: V2 had the same bug but just without the always true if (i) statement.
> Remove the final sleep.
> v2: In V1, I introduced a bug where it would msleep(100) after failure
> and that is a pointless thing to do. Also change the loop to a for loop.
> ---
> drivers/gpu/drm/ast/ast_dp.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/ast/ast_dp.c b/drivers/gpu/drm/ast/ast_dp.c
> index 5d07678b502c..ca022c287785 100644
> --- a/drivers/gpu/drm/ast/ast_dp.c
> +++ b/drivers/gpu/drm/ast/ast_dp.c
> @@ -146,18 +146,19 @@ void ast_dp_power_on_off(struct drm_device *dev, bool on)
> void ast_dp_link_training(struct ast_device *ast)
> {
> struct drm_device *dev = &ast->base;
> - unsigned int i = 10;
> + int i;
>
> - while (i--) {
> - u8 vgacrdc = ast_get_index_reg(ast, AST_IO_VGACRI, 0xdc);
> + for (i = 0; i < 10; i++) {
> + u8 vgacrdc;
>
> - if (vgacrdc & AST_IO_VGACRDC_LINK_SUCCESS)
> - break;
> if (i)
> msleep(100);
> +
> + vgacrdc = ast_get_index_reg(ast, AST_IO_VGACRI, 0xdc);
> + if (vgacrdc & AST_IO_VGACRDC_LINK_SUCCESS)
> + return;
> }
> - if (!i)
> - drm_err(dev, "Link training failed\n");
> + drm_err(dev, "Link training failed\n");
> }
>
> void ast_dp_set_on_off(struct drm_device *dev, bool on)
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
prev parent reply other threads:[~2024-08-12 10:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-12 8:29 Dan Carpenter
2024-08-12 10:43 ` Thomas Zimmermann [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=9ab2e0bb-3c9a-4197-ab73-e0cc82c3efb6@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=airlied@redhat.com \
--cc=dan.carpenter@linaro.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=jfalempe@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@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
all inboxes | Powered by JetHome®