From: Thierry Reding <thierry.reding@gmail.com>
To: Torsten Duwe <duwe@lst.de>
Cc: dri-devel@lists.freedesktop.org, Maxime Ripard <maxime@cerno.tech>
Subject: Re: [PATCH] drm/bridge: analogix-anx78xx: Fix drm_dp_link helper removal
Date: Mon, 2 Dec 2019 15:53:05 +0100 [thread overview]
Message-ID: <20191202145305.GA56608@ulmo> (raw)
In-Reply-To: <20191130145155.86B0F68BE1@verein.lst.de>
[-- Attachment #1.1: Type: text/plain, Size: 2022 bytes --]
On Sat, Nov 30, 2019 at 03:51:55PM +0100, Torsten Duwe wrote:
> drm_dp_link_rate_to_bw_code and ...bw_code_to_link_rate simply divide by
> and multiply with 27000, respectively. Avoid an overflow in the u8 dpcd[0]
> and the multiply+divide alltogether.
This was supposed to be a 1:1 conversion of what the helpers did, but
then I tried to be clever and reuse variables rather than add an
intermediate one and failed to realize that dpcd[0] was u8 and would
therefore overflow with the multiplication.
Personally I think it's slightly nicer to go through the multiply/divide
for consistency with how these helpers are used. MAX_LINK_RATE is a bit
of an exception in that the field occupies the whole register, but most
other registers need to have the fields extracted properly.
In this case it doesn't really matter, so the below is probably good
enough.
Good catch!
Reviewed-by: Thierry Reding <treding@nvidia.com>
> fixes: ff1e8fb68ea06027 ("analogix-anx78xx: Avoid drm_dp_link helpers")
> Signed-off-by: Torsten Duwe <duwe@suse.de>
> ---
> Has anybody actually tested ff1e8fb68ea06027 ? I copied that code in good
> faith for the anx6345 and changed a few other things simultaneously, and
> spent some time wondering why the panel stayed dark.
>
> ---
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> index 41867be03751..864423f59d66 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> @@ -722,10 +722,9 @@ static int anx78xx_dp_link_training(struct anx78xx *anx78xx)
> if (err)
> return err;
>
> - dpcd[0] = drm_dp_max_link_rate(anx78xx->dpcd);
> - dpcd[0] = drm_dp_link_rate_to_bw_code(dpcd[0]);
> err = regmap_write(anx78xx->map[I2C_IDX_TX_P0],
> - SP_DP_MAIN_LINK_BW_SET_REG, dpcd[0]);
> + SP_DP_MAIN_LINK_BW_SET_REG,
> + anx78xx->dpcd[DP_MAX_LINK_RATE]);
> if (err)
> return err;
>
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 159 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
prev parent reply other threads:[~2019-12-02 14:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-30 14:51 [PATCH] drm/bridge: analogix-anx78xx: Fix drm_dp_link helper removal Torsten Duwe
2019-12-02 14:53 ` Thierry Reding [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=20191202145305.GA56608@ulmo \
--to=thierry.reding@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=duwe@lst.de \
--cc=maxime@cerno.tech \
/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.