From: Dmitry Osipenko <digetx@gmail.com>
To: Mikko Perttunen <mperttunen@nvidia.com>,
thierry.reding@gmail.com, jonathanh@nvidia.com
Cc: dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] drm/tegra: Use u64_to_user_ptr helper
Date: Sat, 19 Aug 2017 01:05:14 +0300 [thread overview]
Message-ID: <f16347d6-991e-4d61-eb55-cca24bcf5625@gmail.com> (raw)
In-Reply-To: <20170818161553.27597-5-mperttunen@nvidia.com>
On 18.08.2017 19:15, Mikko Perttunen wrote:
> Use the u64_to_user_ptr helper macro to cast IOCTL argument u64 values
> to user pointers instead of writing out the cast manually.
>
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
> ---
> drivers/gpu/drm/tegra/drm.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index e3331a2bc082..78c98736b0a5 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -389,11 +389,10 @@ int tegra_drm_submit(struct tegra_drm_context *context,
> unsigned int num_relocs = args->num_relocs;
> unsigned int num_waitchks = args->num_waitchks;
> struct drm_tegra_cmdbuf __user *cmdbufs =
> - (void __user *)(uintptr_t)args->cmdbufs;
> - struct drm_tegra_reloc __user *relocs =
> - (void __user *)(uintptr_t)args->relocs;
> + u64_to_user_ptr(args->cmdbufs);
> + struct drm_tegra_reloc __user *relocs = u64_to_user_ptr(args->relocs);
> struct drm_tegra_waitchk __user *waitchks =
> - (void __user *)(uintptr_t)args->waitchks;
> + u64_to_user_ptr(args->waitchks);
What about to factor out 'u64_to_user_ptr()' assignments to reduce messiness a
tad? Like this:
struct drm_tegra_waitchk __user *waitchks;
struct drm_tegra_cmdbuf __user *cmdbufs;
struct drm_tegra_reloc __user *relocs;
...
waitchks = u64_to_user_ptr(args->waitchks);
cmdbufs = u64_to_user_ptr(args->cmdbufs);
relocs = u64_to_user_ptr(args->relocs);
> struct drm_tegra_syncpt syncpt;
> struct host1x *host1x = dev_get_drvdata(drm->dev->parent);
> struct host1x_syncpt *sp;
> @@ -520,7 +519,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
> }
> }
>
> - if (copy_from_user(&syncpt, (void __user *)(uintptr_t)args->syncpts,
> + if (copy_from_user(&syncpt, u64_to_user_ptr(args->syncpts),
What about to define and use 'struct drm_tegra_reloc __user *syncpts' for
consistency with other '__user' definitions?
> sizeof(syncpt))) {
> err = -EFAULT;
> goto fail;
>
--
Dmitry
next prev parent reply other threads:[~2017-08-18 22:05 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-18 16:15 [PATCH 0/4] Miscellaneous improvements to Host1x and TegraDRM Mikko Perttunen
2017-08-18 16:15 ` [PATCH 1/4] gpu: host1x: Enable Tegra186 syncpoint protection Mikko Perttunen
2017-08-18 22:36 ` Dmitry Osipenko
2017-08-19 8:10 ` Mikko Perttunen
2017-08-19 10:09 ` Dmitry Osipenko
2017-08-19 10:35 ` Mikko Perttunen
2017-08-19 11:11 ` Dmitry Osipenko
2017-08-19 11:32 ` Mikko Perttunen
2017-08-19 11:51 ` Dmitry Osipenko
2017-08-19 12:02 ` Dmitry Osipenko
2017-08-20 16:18 ` Dmitry Osipenko
2017-08-20 16:59 ` Dmitry Osipenko
2017-08-20 18:13 ` Dmitry Osipenko
2017-08-18 16:15 ` [PATCH 2/4] gpu: host1x: Enable gather filter Mikko Perttunen
2017-08-19 10:42 ` Dmitry Osipenko
2017-08-19 10:46 ` Mikko Perttunen
2017-08-19 12:05 ` Dmitry Osipenko
2017-08-20 16:24 ` Dmitry Osipenko
2017-08-20 16:44 ` Dmitry Osipenko
2017-08-20 16:59 ` Dmitry Osipenko
2017-08-21 17:27 ` Mikko Perttunen
2017-08-21 17:28 ` Mikko Perttunen
2017-08-18 16:15 ` [PATCH 3/4] gpu: host1x: Improve debug disassembly formatting Mikko Perttunen
2017-08-18 21:54 ` Dmitry Osipenko
2017-08-18 16:15 ` [PATCH 4/4] drm/tegra: Use u64_to_user_ptr helper Mikko Perttunen
2017-08-18 22:05 ` Dmitry Osipenko [this message]
2017-08-19 8:06 ` Mikko Perttunen
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=f16347d6-991e-4d61-eb55-cca24bcf5625@gmail.com \
--to=digetx@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mperttunen@nvidia.com \
--cc=thierry.reding@gmail.com \
/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
Powered by JetHome