[Intel-gfx] [PATCH 2/2] drm/i915: Test all fw tables during mock selftests
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Thu Dec 8 16:52:24 UTC 2016
On 07/12/2016 18:52, Chris Wilson wrote:
> In addition to just testing the fw table we load, during the initial
> mock testing we can test that all tables are valid (so the testing is
> not limited to just the platforms that load that particular table).
>
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> ---
> drivers/gpu/drm/i915/i915_mock_selftests.h | 1 +
> drivers/gpu/drm/i915/intel_uncore.c | 43 +++++++++++++++++++++++-------
> 2 files changed, 34 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_mock_selftests.h b/drivers/gpu/drm/i915/i915_mock_selftests.h
> index 34f32f777b34..d2c469eba1dc 100644
> --- a/drivers/gpu/drm/i915/i915_mock_selftests.h
> +++ b/drivers/gpu/drm/i915/i915_mock_selftests.h
> @@ -11,4 +11,5 @@
> selftest(objects, i915_gem_object_selftests)
> selftest(requests, i915_gem_request_selftest)
> selftest(breadcrumbs, intel_breadcrumbs_selftest)
> +selftest(uncore, intel_uncore_mock_selftests)
> selftest(sanitycheck, i915_mock_sanitycheck) /* keep last */
> diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
> index bd8436b8f3a4..8ad93acbb16f 100644
> --- a/drivers/gpu/drm/i915/intel_uncore.c
> +++ b/drivers/gpu/drm/i915/intel_uncore.c
> @@ -1918,20 +1918,16 @@ intel_uncore_forcewake_for_reg(struct drm_i915_private *dev_priv,
> #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
> #include "i915_selftest.h"
>
> -static int intel_fw_table_check(struct drm_i915_private *i915)
> +static int intel_fw_table_check(const struct intel_forcewake_range *ranges,
> + unsigned int num_ranges,
> + int gen)
> {
> - const struct intel_forcewake_range *ranges;
> - unsigned int num_ranges, i;
> + unsigned int i;
> s32 prev;
>
> - ranges = i915->uncore.fw_domains_table;
> - if (!ranges)
> - return 0;
> -
> - num_ranges = i915->uncore.fw_domains_table_entries;
> for (i = 0, prev = -1; i < num_ranges; i++, ranges++) {
> /* Check that the tabke is watertight */
> - if (WARN_ON(IS_GEN9(i915) && (prev + 1) != (s32)ranges->start))
> + if (WARN_ON(gen >= 9 && (prev + 1) != (s32)ranges->start))
> return -EINVAL;
>
> /* Check that the table never goes backwards */
> @@ -1965,11 +1961,38 @@ static int intel_shadow_table_check(void)
> return 0;
> }
>
> +int intel_uncore_mock_selftests(void)
> +{
> + struct {
> + const struct intel_forcewake_range *ranges;
> + unsigned int num_ranges;
> + int gen;
> + } fw[] = {
> + { __vlv_fw_ranges, ARRAY_SIZE(__vlv_fw_ranges), 7 },
> + { __chv_fw_ranges, ARRAY_SIZE(__chv_fw_ranges), 8 },
> + { __gen9_fw_ranges, ARRAY_SIZE(__gen9_fw_ranges), 9 },
> + };
> + int err, i;
> +
> + for (i = 0; i < ARRAY_SIZE(fw); i++) {
> + err = intel_fw_table_check(fw[i].ranges,
> + fw[i].num_ranges,
> + fw[i].gen);
> + if (err)
> + return err;
> + }
> +
> + return 0;
> +}
> +
> int intel_uncore_late_selftests(struct drm_i915_private *i915)
> {
> int err;
>
> - err = intel_fw_table_check(i915);
> + /* Confirm the table we load is still valid */
> + err = intel_fw_table_check(i915->uncore.fw_domains_table,
> + i915->uncore.fw_domains_table_entries,
> + INTEL_GEN(i915));
> if (err)
> return err;
Idea for another late test:
for (offset = 0; offset < 0x40000; offset++) {
fw_domain = intel_uncore_forcewake_for_reg(dev_priv, { .reg = offset },
FW_REG_READ | FW_REG_WRITE);
if (WARN_ON(fw_domain & ~dev_priv->uncore.fw_domains))
return -EINVAL;
}
And then we could convert the existing related WARNs in the live code
base to GEM_WARN_ONs.
Regards,
Tvrtko
More information about the Intel-gfx
mailing list