[PATCH] drm/xe/xe_oa: Fix unsigned to signed cast in xe_oa_get_oa_config

Umesh Nerlige Ramappa umesh.nerlige.ramappa at intel.com
Tue Jul 29 18:56:26 UTC 2025


On Tue, Jul 29, 2025 at 11:40:31AM -0700, Cavitt, Jonathan wrote:
>-----Original Message-----
>From: Intel-xe <intel-xe-bounces at lists.freedesktop.org> On Behalf Of Umesh Nerlige Ramappa
>Sent: Tuesday, July 29, 2025 11:21 AM
>To: intel-xe at lists.freedesktop.org
>Subject: [PATCH] drm/xe/xe_oa: Fix unsigned to signed cast in xe_oa_get_oa_config
>>
>> Static analysis flagged an issue with casting unsigned value to signed.
>> Fix it by using an unsigned parameter in function definition.
>>
>> Fixes: 1db9a9dc90ae ("drm/xe/oa: OA stream initialization (OAG)")
>> Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>
>> ---
>>  drivers/gpu/drm/xe/xe_oa.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
>> index 5729e7d3e335..e166547f43e7 100644
>> --- a/drivers/gpu/drm/xe/xe_oa.c
>> +++ b/drivers/gpu/drm/xe/xe_oa.c
>> @@ -178,7 +178,7 @@ static struct xe_oa_config *xe_oa_config_get(struct xe_oa_config *oa_config)
>>  	return kref_get_unless_zero(&oa_config->ref) ? oa_config : NULL;
>>  }
>>
>> -static struct xe_oa_config *xe_oa_get_oa_config(struct xe_oa *oa, int metrics_set)
>> +static struct xe_oa_config *xe_oa_get_oa_config(struct xe_oa *oa, u32 metrics_set)
>
>I mean, the alternative is that we change the metric_set parameter in xe_oa_open_param
>to be an integer instead of a u32, but that might cause the same static analysis problem with
>xe_oa_set_prop_metric_set, so this is definitely the better solution of the two.

Also, the metric id is expected to be >= 0 always, so unsigned is good 
enough to handle all such references.

>
>Reviewed-by: Jonathan Cavitt <jonathan.cavitt at intel.com>

Thanks,
Umesh

>-Jonathan Cavitt
>
>>  {
>>  	struct xe_oa_config *oa_config;
>>
>> --
>> 2.43.0
>>
>>


More information about the Intel-xe mailing list