[PATCH i-g-t] tests/intel/xe_oa: Avoid divide by zero SIGFPE

Umesh Nerlige Ramappa umesh.nerlige.ramappa at intel.com
Thu May 15 21:49:46 UTC 2025


On Thu, May 15, 2025 at 01:18:04PM -0700, Ashutosh Dixit wrote:
>It is planned for future OA units to have 0 engines attached to them. Avoid
>divide by zero SIGFPE for these cases.
>
>Signed-off-by: Ashutosh Dixit <ashutosh.dixit at intel.com>

LGTM,

Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>

Umesh
>---
> tests/intel/xe_oa.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/tests/intel/xe_oa.c b/tests/intel/xe_oa.c
>index 1576479d98..73841a359d 100644
>--- a/tests/intel/xe_oa.c
>+++ b/tests/intel/xe_oa.c
>@@ -445,7 +445,7 @@ static struct drm_xe_engine_class_instance *oa_unit_engine(int fd, int n)
> 		oau = (struct drm_xe_oa_unit *)poau;
>
> 		if (i == n) {
>-			hwe = &oau->eci[random() % oau->num_engines];
>+			hwe = oau->num_engines ? &oau->eci[random() % oau->num_engines] : NULL;
> 			break;
> 		}
> 		poau += sizeof(*oau) + oau->num_engines * sizeof(oau->eci[0]);
>-- 
>2.48.1
>


More information about the igt-dev mailing list