All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: Ben Skeggs <bskeggs@redhat.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] nouveau/nvkm/subdev/clk/gk20a.c: fix wrong do_div() usage
Date: Fri, 4 Dec 2015 18:38:01 +0100	[thread overview]
Message-ID: <20151204173801.GA30117@ulmo.nvidia.com> (raw)
In-Reply-To: <alpine.LFD.2.20.1511031653580.630@knanqh.ubzr>


[-- Attachment #1.1: Type: text/plain, Size: 1117 bytes --]

On Tue, Nov 03, 2015 at 05:01:46PM -0500, Nicolas Pitre wrote:
> do_div() must only be used with a u64 dividend.
> 
> Signed-off-by: Nicolas Pitre <nico@linaro.org>
> 
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c
> index 254094ab7f..5da2aa8cc3 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/gk20a.c
> @@ -141,9 +141,8 @@ gk20a_pllg_calc_rate(struct gk20a_clk *clk)
>  
>  	rate = clk->parent_rate * clk->n;
>  	divider = clk->m * pl_to_div[clk->pl];
> -	do_div(rate, divider);
>  
> -	return rate / 2;
> +	return rate / divider / 2;
>  }
>  
>  static int

This causes build breakage on 32-bit ARM. I'm also confused by the
commit message because the code that I'm looking at has u64 rate and u32
divider, which matches the types given in include/asm-generic/div64.h:

 * The semantics of do_div() are:
 *
 * uint32_t do_div(uint64_t *n, uint32_t base)
 * {
 * 	uint32_t remainder = *n % base;
 * 	*n = *n / base;
 * 	return remainder;
 * }

Thierry

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-12-04 17:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-03 22:01 [PATCH] nouveau/nvkm/subdev/clk/gk20a.c: fix wrong do_div() usage Nicolas Pitre
2015-12-04 17:38 ` Thierry Reding [this message]
2015-12-04 19:58   ` Nicolas Pitre

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=20151204173801.GA30117@ulmo.nvidia.com \
    --to=thierry.reding@gmail.com \
    --cc=bskeggs@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=nicolas.pitre@linaro.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 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.