From: Guillaume Tucker <guillaume.tucker@collabora.com>
To: Petri Latvala <petri.latvala@intel.com>
Cc: igt-dev@lists.freedesktop.org,
Kevin Hilman <khilman@baylibre.com>,
intel-gfx@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t] i915/gem_create: Do not build create-clear for MIPS
Date: Wed, 3 Apr 2019 09:25:29 +0200 [thread overview]
Message-ID: <2a32a670-ca41-b8a3-1c63-26f0dc9d6821@collabora.com> (raw)
In-Reply-To: <20190402083512.GH4038@platvala-desk.ger.corp.intel.com>
On 02/04/2019 09:35, Petri Latvala wrote:
> On Mon, Apr 01, 2019 at 04:39:24PM +0200, Guillaume Tucker wrote:
>> The MIPS architecture doesn't provide the hardware atomics that are
>> required for the "create-clear" sub-test such as
>> __sync_add_and_fetch(). As a simple and pragmatic solution, disable
>> this sub-test when building for MIPS. A better approach would be to
>> add a fallback implementation for these operations.
>>
>> Fixes: 6727e17c00b2 ("i915/gem_create: Verify that all new objects are clear")
>> Signed-off-by: Guillaume Tucker <guillaume.tucker@collabora.com>
>> ---
>> tests/i915/gem_create.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/tests/i915/gem_create.c b/tests/i915/gem_create.c
>> index 2a861ca8a7ec..8a48496e6c19 100644
>> --- a/tests/i915/gem_create.c
>> +++ b/tests/i915/gem_create.c
>> @@ -142,6 +142,7 @@ static void invalid_nonaligned_size(int fd)
>> gem_close(fd, handle);
>> }
>>
>> +#if !defined(__mips__) /* MIPS doesn't provide the required hardware atomics */
>> static uint64_t get_npages(uint64_t *global, uint64_t npages)
>> {
>> uint64_t try, old, max;
>> @@ -208,6 +209,7 @@ static void always_clear(int i915, int timeout)
>> for (int i = 0; i < ncpus; i++)
>> pthread_join(thread[i], NULL);
>> }
>> +#endif /* !defined(__mips__) */
>>
>> igt_main
>> {
>> @@ -231,6 +233,8 @@ igt_main
>> igt_subtest("create-invalid-nonaligned")
>> invalid_nonaligned_size(fd);
>>
>> +#if !defined(__mips__)
>> igt_subtest("create-clear")
>> always_clear(fd, 30);
>> +#endif
>> }
>
>
> It's a bit ugly. I wonder how much work a fallback mechanism would be?
Sorry I should have sent this as RFC.
> The test is i915 specific and using those on non-x86 architectures
> sounds silly. We could limit building tests/i915/* only if
> host_machine.cpu_family() is x86 or x86_64. But that requires
> revisiting this issue if ever the day comes when i915 can be used on
> other architectures *cough*.
Right, I thought it might not be worth implementing fallback
functions if there is no MIPS hardware on which this test can be
run. Still it would be a shame to leave i-g-t failing to build
on MIPS.
> Apropos, compile-testing on MIPS in gitlab-CI?
This issue was actually hit while building the KernelCI root file
system with i-g-t tests. We're starting to add some MIPS
platforms, so running the generic DRM/KMS tests on them might
start to make sense at some point (cc khilman).
And yes I guess it seems worth considering adding MIPS to
Gitlab-CI as it only appears to be covering x86, armhf and
arm64 (although I did fix an armhf build issue a few weeks ago).
> A compile-tested-only fallback mechanism suggestion, and a bad spot
> for placing the fallback functions:
Thanks, I agree that does look like a sustainable way forward.
We don't quite have a MIPS platform to test that yet in KernelCI,
so hopefully QEMU can be used to test a fallback implementation.
I guess adding placeholder functions as in your example with
igt_assert_f() statements would just add some technical debt with
little added benefit, so I'll work on a v2 with something that
works. Meanwhile we'll just skip i-g-t KernelCI builds on MIPS.
> diff --git a/meson.build b/meson.build
> index 557400a5..0552e858 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -246,6 +246,9 @@ endif
> have = cc.has_function('memfd_create', prefix : '''#include <sys/mman.h>''', args : '-D_GNU_SOURCE')
> config.set10('HAVE_MEMFD_CREATE', have)
>
> +have_atomics = cc.compiles('void f() { int x, y; __sync_add_and_fetch(&x, y); }')
> +config.set10('HAVE_BUILTIN_ATOMICS', have_atomics)
> +
> add_project_arguments('-D_GNU_SOURCE', language : 'c')
> add_project_arguments('-include', 'config.h', language : 'c')
>
> diff --git a/tests/i915/gem_create.c b/tests/i915/gem_create.c
> index 2a861ca8..615bb475 100644
> --- a/tests/i915/gem_create.c
> +++ b/tests/i915/gem_create.c
> @@ -62,6 +62,18 @@ IGT_TEST_DESCRIPTION("This is a test for the extended & old gem_create ioctl,"
> " that includes allocation of object from stolen memory"
> " and shmem.");
>
> +#if !HAVE_BUILTIN_ATOMICS
> +int __sync_add_and_fetch(void *ptr, uint64_t val)
> +{
> + igt_assert_f(false, "Don't have builtin atomics\n");
> +}
> +
> +int __sync_val_compare_and_swap(void *ptr, uint64_t old, uint64_t new)
> +{
> + igt_assert_f(false, "Don't have builtin atomics\n");
> +}
> +#endif
> +
> #define CLEAR(s) memset(&s, 0, sizeof(s))
> #define PAGE_SIZE 4096
Thanks,
Guillaume
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-04-03 7:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-01 14:39 [igt-dev] [PATCH i-g-t] i915/gem_create: Do not build create-clear for MIPS Guillaume Tucker
2019-04-02 5:27 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-04-02 6:59 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-04-02 8:35 ` [igt-dev] [PATCH i-g-t] " Petri Latvala
2019-04-03 7:25 ` Guillaume Tucker [this message]
2019-06-05 20:46 ` Guillaume Tucker
2019-04-02 9:12 ` [igt-dev] ✓ Fi.CI.BAT: success for i915/gem_create: Do not build create-clear for MIPS (rev2) Patchwork
2019-04-02 14:34 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
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=2a32a670-ca41-b8a3-1c63-26f0dc9d6821@collabora.com \
--to=guillaume.tucker@collabora.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=khilman@baylibre.com \
--cc=petri.latvala@intel.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