All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.william.auld@gmail.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes
Date: Wed, 22 Feb 2023 17:10:55 +0000	[thread overview]
Message-ID: <CAM0jSHOkr+d=Zy8MuKoLMCA8sAZCP1JMjFLR0mEtMvN4R--F-g@mail.gmail.com> (raw)
In-Reply-To: <20230222145934.d5xmmfyle2iwyhnw@ldmartin-desk2.jf.intel.com>

On Wed, 22 Feb 2023 at 14:59, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
>
> On Wed, Feb 22, 2023 at 10:02:08AM +0000, Matthew Auld wrote:
> >On Tue, 21 Feb 2023 at 23:34, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
> >>
> >> In order to avoid  -Werror=missing-prototypes, add the prototypes and
> >> move the functions to the end of the file, surrounded by
> >> `#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)`.
> >
> >Is everything under tests/ not excluded from compilation when !XE_KUNIT_TEST?
>
> yes, except the ifdef is not in tests/. Example:
> drivers/gpu/drm/xe/tests/xe_bo.c

AFAICT xe/tests is only compiled if XE_KUNIT_TEST is enabled (looking
at the Makefile). tests/xe_bo.c is included at the bottom of xe_bo.c
but that is also wrapped in ifdef. So not seeing why we need to add
the ifdef stuff directly in tests/xe_bo.c, for example.

>
> The way the kunit tests in xe are split is: each .o in tests/ will
> create a separate module. In order to test a function like we are
> doing, the function needs to be declared !static and exported so the
> other module can call it.
>
> There are other possible ways to test functions on a different
> compilation unit: https://kunit.dev/third_party/kernel/docs/tips.html?highlight=static%20function#testing-static-functions
> I'm not so familiar with kunit yet to be able to say which one
> is better for our case, so I just went with the easy fix.
>
> +Thomas
>
> Lucas De Marchi
>
> >
> >>
> >> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> >> ---
> >>  drivers/gpu/drm/xe/tests/xe_bo.c      | 54 +++++++++++++++------------
> >>  drivers/gpu/drm/xe/tests/xe_dma_buf.c |  2 +
> >>  drivers/gpu/drm/xe/tests/xe_migrate.c |  6 +++
> >>  3 files changed, 39 insertions(+), 23 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/xe/tests/xe_bo.c b/drivers/gpu/drm/xe/tests/xe_bo.c
> >> index 87ac21cc8ca9..2c94ddaacda6 100644
> >> --- a/drivers/gpu/drm/xe/tests/xe_bo.c
> >> +++ b/drivers/gpu/drm/xe/tests/xe_bo.c
> >> @@ -141,29 +141,6 @@ static void ccs_test_run_gt(struct xe_device *xe, struct xe_gt *gt,
> >>         xe_bo_put(bo);
> >>  }
> >>
> >> -static int ccs_test_run_device(struct xe_device *xe)
> >> -{
> >> -       struct kunit *test = xe_cur_kunit();
> >> -       struct xe_gt *gt;
> >> -       int id;
> >> -
> >> -       if (!xe_device_has_flat_ccs(xe)) {
> >> -               kunit_info(test, "Skipping non-flat-ccs device.\n");
> >> -               return 0;
> >> -       }
> >> -
> >> -       for_each_gt(gt, xe, id)
> >> -               ccs_test_run_gt(xe, gt, test);
> >> -
> >> -       return 0;
> >> -}
> >> -
> >> -void xe_ccs_migrate_kunit(struct kunit *test)
> >> -{
> >> -       xe_call_for_each_device(ccs_test_run_device);
> >> -}
> >> -EXPORT_SYMBOL(xe_ccs_migrate_kunit);
> >> -
> >>  static int evict_test_run_gt(struct xe_device *xe, struct xe_gt *gt, struct kunit *test)
> >>  {
> >>         struct xe_bo *bo, *external;
> >> @@ -278,6 +255,8 @@ static int evict_test_run_gt(struct xe_device *xe, struct xe_gt *gt, struct kuni
> >>         return 0;
> >>  }
> >>
> >> +#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
> >> +
> >>  static int evict_test_run_device(struct xe_device *xe)
> >>  {
> >>         struct kunit *test = xe_cur_kunit();
> >> @@ -296,8 +275,37 @@ static int evict_test_run_device(struct xe_device *xe)
> >>         return 0;
> >>  }
> >>
> >> +void xe_bo_evict_kunit(struct kunit *test);
> >> +
> >>  void xe_bo_evict_kunit(struct kunit *test)
> >>  {
> >>         xe_call_for_each_device(evict_test_run_device);
> >>  }
> >>  EXPORT_SYMBOL(xe_bo_evict_kunit);
> >> +
> >> +static int ccs_test_run_device(struct xe_device *xe)
> >> +{
> >> +       struct kunit *test = xe_cur_kunit();
> >> +       struct xe_gt *gt;
> >> +       int id;
> >> +
> >> +       if (!xe_device_has_flat_ccs(xe)) {
> >> +               kunit_info(test, "Skipping non-flat-ccs device.\n");
> >> +               return 0;
> >> +       }
> >> +
> >> +       for_each_gt(gt, xe, id)
> >> +               ccs_test_run_gt(xe, gt, test);
> >> +
> >> +       return 0;
> >> +}
> >> +
> >> +void xe_ccs_migrate_kunit(struct kunit *test);
> >> +
> >> +void xe_ccs_migrate_kunit(struct kunit *test)
> >> +{
> >> +       xe_call_for_each_device(ccs_test_run_device);
> >> +}
> >> +EXPORT_SYMBOL(xe_ccs_migrate_kunit);
> >> +
> >> +#endif
> >> diff --git a/drivers/gpu/drm/xe/tests/xe_dma_buf.c b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> >> index 615d22e3f731..d8ad135d0e04 100644
> >> --- a/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> >> +++ b/drivers/gpu/drm/xe/tests/xe_dma_buf.c
> >> @@ -252,6 +252,8 @@ static int dma_buf_run_device(struct xe_device *xe)
> >>         return 0;
> >>  }
> >>
> >> +void xe_dma_buf_kunit(struct kunit *test);
> >> +
> >>  void xe_dma_buf_kunit(struct kunit *test)
> >>  {
> >>         xe_call_for_each_device(dma_buf_run_device);
> >> diff --git a/drivers/gpu/drm/xe/tests/xe_migrate.c b/drivers/gpu/drm/xe/tests/xe_migrate.c
> >> index 03a60d5b42f1..7be0c2543916 100644
> >> --- a/drivers/gpu/drm/xe/tests/xe_migrate.c
> >> +++ b/drivers/gpu/drm/xe/tests/xe_migrate.c
> >> @@ -352,6 +352,8 @@ static void xe_migrate_sanity_test(struct xe_migrate *m, struct kunit *test)
> >>         xe_bo_vunmap(m->pt_bo);
> >>  }
> >>
> >> +#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
> >> +
> >>  static int migrate_test_run_device(struct xe_device *xe)
> >>  {
> >>         struct kunit *test = xe_cur_kunit();
> >> @@ -371,8 +373,12 @@ static int migrate_test_run_device(struct xe_device *xe)
> >>         return 0;
> >>  }
> >>
> >> +void xe_migrate_sanity_kunit(struct kunit *test);
> >> +
> >>  void xe_migrate_sanity_kunit(struct kunit *test)
> >>  {
> >>         xe_call_for_each_device(migrate_test_run_device);
> >>  }
> >>  EXPORT_SYMBOL(xe_migrate_sanity_kunit);
> >> +
> >> +#endif
> >> --
> >> 2.39.0
> >>

  reply	other threads:[~2023-02-22 17:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21 23:33 [Intel-xe] [PATCH 0/6] Cleanup warnings (fix build with W=1) Lucas De Marchi
2023-02-21 23:33 ` [Intel-xe] [PATCH 1/6] drm/xe: Make local functions static Lucas De Marchi
2023-02-22  9:48   ` Matthew Auld
2023-02-21 23:33 ` [Intel-xe] [PATCH 2/6] drm/xe: Fix application of LRC tunings Lucas De Marchi
2023-02-22 10:16   ` Matthew Auld
2023-02-21 23:33 ` [Intel-xe] [PATCH 3/6] drm/xe: Fix kunit integration due to missing prototypes Lucas De Marchi
2023-02-22 10:02   ` Matthew Auld
2023-02-22 14:59     ` Lucas De Marchi
2023-02-22 17:10       ` Matthew Auld [this message]
2023-02-22 17:42         ` Lucas De Marchi
2023-02-21 23:33 ` [Intel-xe] [PATCH 4/6] drm/xe: Remove unused functions Lucas De Marchi
2023-02-22 10:05   ` Matthew Auld
2023-02-21 23:33 ` [Intel-xe] [PATCH 5/6] drm/xe: Add missing doc for xe parameter Lucas De Marchi
2023-02-22 10:06   ` Matthew Auld
2023-02-21 23:33 ` [Intel-xe] [PATCH 6/6] drm/xe: Add missing include xe_wait_user_fence.h Lucas De Marchi
2023-02-22 10:07   ` Matthew Auld
2023-02-23  0:37     ` Lucas De Marchi

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='CAM0jSHOkr+d=Zy8MuKoLMCA8sAZCP1JMjFLR0mEtMvN4R--F-g@mail.gmail.com' \
    --to=matthew.william.auld@gmail.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@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 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.