[PATCH 3/5] drm/xe/mocs: Move warn/assertion up

Matt Roper matthew.d.roper at intel.com
Thu Feb 29 21:22:51 UTC 2024


On Tue, Feb 27, 2024 at 10:10:46PM -0800, Lucas De Marchi wrote:
> The warn-once in __init_mocs_table() to make sure there's an index set
> for unused entries is more a sanity check that should be done as the
> first thing in that function. The kunit test replicates the same check,
> so also move it up and turn it into a failure condition for the test.
> 
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>

Reviewed-by: Matt Roper <matthew.d.roper at intel.com>

> ---
>  drivers/gpu/drm/xe/tests/xe_mocs.c | 5 +++--
>  drivers/gpu/drm/xe/xe_mocs.c       | 4 +++-
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/tests/xe_mocs.c b/drivers/gpu/drm/xe/tests/xe_mocs.c
> index 7c91e01c47a3a..9787546e42249 100644
> --- a/drivers/gpu/drm/xe/tests/xe_mocs.c
> +++ b/drivers/gpu/drm/xe/tests/xe_mocs.c
> @@ -79,11 +79,12 @@ static void read_mocs_table(struct xe_gt *gt,
>  
>  	struct kunit *test = xe_cur_kunit();
>  
> +	KUNIT_EXPECT_TRUE_MSG(test, info->unused_entries_index,
> +			      "Unused entries index should have been defined\n");
> +
>  	ret = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
>  	KUNIT_ASSERT_EQ_MSG(test, ret, 0, "Forcewake Failed.\n");
>  	mocs_dbg(&gt_to_xe(gt)->drm, "Global MOCS entries:%d\n", info->n_entries);
> -	drm_WARN_ONCE(&xe->drm, !info->unused_entries_index,
> -		      "Unused entries index should have been defined\n");
>  
>  	for (i = 0; i < info->n_entries; i++) {
>  		mocs = get_entry_control(info, i);
> diff --git a/drivers/gpu/drm/xe/xe_mocs.c b/drivers/gpu/drm/xe/xe_mocs.c
> index bdb755b963238..60ab34fd213fb 100644
> --- a/drivers/gpu/drm/xe/xe_mocs.c
> +++ b/drivers/gpu/drm/xe/xe_mocs.c
> @@ -470,9 +470,11 @@ static void __init_mocs_table(struct xe_gt *gt,
>  	unsigned int i;
>  	u32 mocs;
>  
> -	mocs_dbg(&gt_to_xe(gt)->drm, "mocs entries: %d\n", info->n_entries);
>  	drm_WARN_ONCE(&xe->drm, !info->unused_entries_index,
>  		      "Unused entries index should have been defined\n");
> +
> +	mocs_dbg(&gt_to_xe(gt)->drm, "mocs entries: %d\n", info->n_entries);
> +
>  	for (i = 0; i < info->n_entries; i++) {
>  		mocs = get_entry_control(info, i);
>  
> -- 
> 2.43.0
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation


More information about the Intel-xe mailing list