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 v3 6/6] drm/tegra: Use u64_to_user_ptr helper
Date: Sat, 30 Sep 2017 05:44:46 +0300 [thread overview]
Message-ID: <23bcc5c9-3706-1200-51c9-a48934254343@gmail.com> (raw)
In-Reply-To: <20170928125044.32516-7-mperttunen@nvidia.com>
On 28.09.2017 15:50, 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. Also do
> some other cleanup with user pointers to make them stand out more
> and look cleaner.
>
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
> ---
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Tested-by: Dmitry Osipenko <digetx@gmail.com>
> drivers/gpu/drm/tegra/drm.c | 29 +++++++++++++++--------------
> 1 file changed, 15 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index 130d193192ee..943bdf88c4a2 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -386,12 +386,10 @@ int tegra_drm_submit(struct tegra_drm_context *context,
> unsigned int num_cmdbufs = args->num_cmdbufs;
> 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;
> - struct drm_tegra_waitchk __user *waitchks =
> - (void __user *)(uintptr_t)args->waitchks;
> + struct drm_tegra_cmdbuf __user *user_cmdbufs;
> + struct drm_tegra_reloc __user *user_relocs;
> + struct drm_tegra_waitchk __user *user_waitchks;
> + struct drm_tegra_syncpt __user *user_syncpt;
> struct drm_tegra_syncpt syncpt;
> struct host1x *host1x = dev_get_drvdata(drm->dev->parent);
> struct drm_gem_object **refs;
> @@ -400,6 +398,11 @@ int tegra_drm_submit(struct tegra_drm_context *context,
> unsigned int num_refs;
> int err;
>
> + user_cmdbufs = u64_to_user_ptr(args->cmdbufs);
> + user_relocs = u64_to_user_ptr(args->relocs);
> + user_waitchks = u64_to_user_ptr(args->waitchks);
> + user_syncpt = u64_to_user_ptr(args->syncpts);
> +
> /* We don't yet support other than one syncpt_incr struct per submit */
> if (args->num_syncpts != 1)
> return -EINVAL;
> @@ -440,7 +443,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
> struct tegra_bo *obj;
> u64 offset;
>
> - if (copy_from_user(&cmdbuf, cmdbufs, sizeof(cmdbuf))) {
> + if (copy_from_user(&cmdbuf, user_cmdbufs, sizeof(cmdbuf))) {
> err = -EFAULT;
> goto fail;
> }
> @@ -476,7 +479,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
>
> host1x_job_add_gather(job, bo, cmdbuf.words, cmdbuf.offset);
> num_cmdbufs--;
> - cmdbufs++;
> + user_cmdbufs++;
> }
>
> /* copy and resolve relocations from submit */
> @@ -485,7 +488,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
> struct tegra_bo *obj;
>
> err = host1x_reloc_copy_from_user(&job->relocarray[num_relocs],
> - &relocs[num_relocs], drm,
> + &user_relocs[num_relocs], drm,
> file);
> if (err < 0)
> goto fail;
> @@ -519,9 +522,8 @@ int tegra_drm_submit(struct tegra_drm_context *context,
> struct host1x_waitchk *wait = &job->waitchk[num_waitchks];
> struct tegra_bo *obj;
>
> - err = host1x_waitchk_copy_from_user(wait,
> - &waitchks[num_waitchks],
> - file);
> + err = host1x_waitchk_copy_from_user(
> + wait, &user_waitchks[num_waitchks], file);
> if (err < 0)
> goto fail;
>
> @@ -539,8 +541,7 @@ int tegra_drm_submit(struct tegra_drm_context *context,
> }
> }
>
> - if (copy_from_user(&syncpt, (void __user *)(uintptr_t)args->syncpts,
> - sizeof(syncpt))) {
> + if (copy_from_user(&syncpt, user_syncpt, sizeof(syncpt))) {
> err = -EFAULT;
> goto fail;
> }
>
next prev parent reply other threads:[~2017-09-30 2:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-28 12:50 [PATCH v3 0/6] Miscellaneous improvements to Host1x and TegraDRM Mikko Perttunen
2017-09-28 12:50 ` [PATCH v3 1/6] gpu: host1x: Enable Tegra186 syncpoint protection Mikko Perttunen
2017-09-30 2:41 ` Dmitry Osipenko
2017-09-30 7:01 ` Mikko Perttunen
2017-10-19 12:49 ` Thierry Reding
2017-09-28 12:50 ` [PATCH v3 2/6] gpu: host1x: Enable gather filter Mikko Perttunen
2017-09-28 12:50 ` [PATCH v3 3/6] gpu: host1x: Improve debug disassembly formatting Mikko Perttunen
2017-09-28 13:29 ` Joe Perches
2017-09-28 12:50 ` [PATCH v3 4/6] gpu: host1x: Disassemble more instructions Mikko Perttunen
2017-09-30 2:44 ` Dmitry Osipenko
2017-09-28 12:50 ` [PATCH v3 5/6] gpu: host1x: Fix incorrect comment for channel_request Mikko Perttunen
2017-09-28 12:50 ` [PATCH v3 6/6] drm/tegra: Use u64_to_user_ptr helper Mikko Perttunen
2017-09-30 2:44 ` Dmitry Osipenko [this message]
2017-10-19 12:00 ` [PATCH v3 0/6] Miscellaneous improvements to Host1x and TegraDRM Thierry Reding
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=23bcc5c9-3706-1200-51c9-a48934254343@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
all inboxes | Powered by JetHome®