From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 3/3] igt/gem_userptr_blits: Verify that userptr bo work on unshared memory
Date: Fri, 11 Jul 2014 11:45:25 +0100 [thread overview]
Message-ID: <53BFC045.1090109@linux.intel.com> (raw)
In-Reply-To: <1405071640-29692-3-git-send-email-chris@chris-wilson.co.uk>
On 07/11/2014 10:40 AM, Chris Wilson wrote:
> If the parent passes a userptr to some private memory, we expect to
> still be able to use the userptr in the child.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> tests/gem_userptr_blits.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 52 insertions(+)
>
> diff --git a/tests/gem_userptr_blits.c b/tests/gem_userptr_blits.c
> index 9cf681b..454db58 100644
> --- a/tests/gem_userptr_blits.c
> +++ b/tests/gem_userptr_blits.c
> @@ -542,6 +542,55 @@ static int test_invalid_mapping(int fd)
> return 0;
> }
>
> +static void test_forked_access(int fd)
> +{
> + uint32_t handle1, handle2;
> + void *ptr1, *ptr2;
> + int ret;
> +
> + ret = posix_memalign(&ptr1, PAGE_SIZE, PAGE_SIZE);
> + igt_assert(ret == 0);
> +
> + ret = madvise(ptr1, PAGE_SIZE, MADV_DONTFORK);
> + igt_assert(ret == 0);
> +
> + ret = gem_userptr(fd, ptr1, PAGE_SIZE, 0, &handle1);
> + igt_assert(ret == 0);
> +
> + ret = posix_memalign(&ptr2, PAGE_SIZE, PAGE_SIZE);
> + igt_assert(ret == 0);
> +
> + ret = madvise(ptr2, PAGE_SIZE, MADV_DONTFORK);
> + igt_assert(ret == 0);
> +
> + ret = gem_userptr(fd, ptr2, PAGE_SIZE, 0, &handle2);
> + igt_assert(ret == 0);
> +
> + memset(ptr1, 0x1, PAGE_SIZE);
> + memset(ptr2, 0x2, PAGE_SIZE);
> +
> + igt_fork(child, 1) {
> + copy(fd, handle1, handle2, 0);
> + }
> + igt_waitchildren();
> +
> + gem_userptr_sync(fd, handle1);
> + gem_userptr_sync(fd, handle2);
> +
> + gem_close(fd, handle1);
> + gem_close(fd, handle2);
> +
> + igt_assert(memcmp(ptr1, ptr2, PAGE_SIZE) == 0);
> +
> + ret = madvise(ptr1, PAGE_SIZE, MADV_DOFORK);
> + igt_assert(ret == 0);
> + free(ptr1);
> +
> + ret = madvise(ptr2, PAGE_SIZE, MADV_DOFORK);
> + igt_assert(ret == 0);
> + free(ptr2);
> +}
> +
> static int test_forbidden_ops(int fd)
> {
> void *ptr;
> @@ -1108,6 +1157,9 @@ int main(int argc, char **argv)
> igt_subtest("invalid-mapping")
> test_invalid_mapping(fd);
>
> + igt_subtest("forked-access")
> + test_forked_access(fd);
> +
> igt_subtest("forbidden-operations")
> test_forbidden_ops(fd);
>
>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
next prev parent reply other threads:[~2014-07-11 10:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-11 9:40 [PATCH 1/3] Wait for any pid in order to reap failure quicker Chris Wilson
2014-07-11 9:40 ` [PATCH 2/3] igt/gem_userptr_blits: Shared memory allocations Chris Wilson
2014-07-11 10:30 ` Tvrtko Ursulin
2014-07-11 9:40 ` [PATCH 3/3] igt/gem_userptr_blits: Verify that userptr bo work on unshared memory Chris Wilson
2014-07-11 10:45 ` Tvrtko Ursulin [this message]
2014-07-11 11:56 ` [PATCH 1/3] Wait for any pid in order to reap failure quicker Tvrtko Ursulin
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=53BFC045.1090109@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.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.