Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp710489pxb; Wed, 16 Feb 2022 02:41:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdOB/sCQIeNj2SBxOIJy2zX3bKYyYzhIgiiBHqAtJx/5PmekafNKe1lziBAAhmi0FSLKfy X-Received: by 2002:a05:6402:18:b0:410:86cd:9dce with SMTP id d24-20020a056402001800b0041086cd9dcemr2287389edu.70.1645008070057; Wed, 16 Feb 2022 02:41:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645008070; cv=none; d=google.com; s=arc-20160816; b=0fk6yZjC+cdsBQzFu658DOc76lrMbXLoPw7WtJf88tj08KszYkBq86k6lrmqfM/7xv HfM0VgcKlJiJsd2ncGbnIO5Ronm1aABtNn8l2nW8kLfYb1b9qTz/ydxS/LG/QgeQvjbB hqnIFPfi2tiF8tf59861xTXMyxk13mqBG5qSamk64WvBuqGmkhocIpDASa9ZkFrl4ad9 U6AUaqRA8qMilGpQvRgWYdBcIAH5frYqYG5JusqyICDukjzKBldUMGmBCN5EXHfW/uFM 7PJ3wYeKP1q8v6XStpttV2Fs8f5GYOS24ZoNMZucdN41dYLb76AbFQ8rkFFu0YNP9eN2 5hew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:references:organization:in-reply-to:subject:cc:to :from:dkim-signature; bh=bX741+JNnlir0irEqXtMj8VAE8Qi0NtZqgzKvXG0cyg=; b=mWAEQO/skVgHvEdXywJ3ZGGXbBgIJpBa3kxo9VgG9CUPIHPBY3tWVGOtuQu/2MiSjo qCF9He1ZzhQk/ebXamnq1CV0dc3hJd8J1qas6+RwgDL9g9Fq2sNd06IIlNFjKS423ikZ wtt/yCk2A97HfKF2YHyWQGubYFlerD0K9zo1qP9rhKfrvKr/gnYePfHhQ+USkGA/3x2S /0dDHUHVXiYw6+yucuPhEnREn8D9aBnjRgIlRyoSVOWlGqYNM+mShijvtOD7OkBDPqSl JBz2EEtpa+BrCYnOWvdBPSb7/hRhBM9MjmPPNfex8/ZwANp0G0i4Rtshlcu8VOWmKlNv lTKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DzsbVIDB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq3si29102549ejc.417.2022.02.16.02.40.45; Wed, 16 Feb 2022 02:41:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DzsbVIDB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229510AbiBPKdy (ORCPT + 99 others); Wed, 16 Feb 2022 05:33:54 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbiBPKdv (ORCPT ); Wed, 16 Feb 2022 05:33:51 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B83552B0B14; Wed, 16 Feb 2022 02:33:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645007619; x=1676543619; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=0EU2xKs5/be5ABCYsSQiiugsjJ0zBzNPzGsy9hvHN5k=; b=DzsbVIDBAlYKciujwIhe2+EilIPILebVDzsnb4+kwmSfzv5s2EVsxBh0 nLP/M0EQI6HoPDaYTl9yOZx0HC4SgDIUMq6fEfQ1OdVHoQ4FeA+e0Fb43 u3defYrG4RkTh3IwwLxEeJhUo+27FVMhK5EU+tHZAmAHVX2ZxYD+HzU1U 5iKlRFDWMh7Zc3V8reUm1QmvWuJsnJtrIW2pRQrOAA+oL/Tq549obAv5H 0S+AVyIjooY/s8w7++8pn8dwQks7NDTb5/PekBdLk1DyPIKQVU8+eixN+ sKTT7SDso8zoaNjTdD599Y5kjXIvLkAkEUL9tkwJ/zKIc1Dyi3AG6dffg Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10259"; a="275156373" X-IronPort-AV: E=Sophos;i="5.88,373,1635231600"; d="scan'208";a="275156373" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2022 02:33:39 -0800 X-IronPort-AV: E=Sophos;i="5.88,373,1635231600"; d="scan'208";a="502968616" Received: from rbilei-mobl.ger.corp.intel.com (HELO localhost) ([10.252.13.113]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2022 02:33:35 -0800 From: Jani Nikula To: Tvrtko Ursulin , Ville =?utf-8?B?U3ly?= =?utf-8?B?asOkbMOk?= Cc: Jiapeng Chong , airlied@linux.ie, intel-gfx@lists.freedesktop.org, Abaci Robot , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, christian.koenig@amd.com, linaro-mm-sig@lists.linaro.org, rodrigo.vivi@intel.com, sumit.semwal@linaro.org, linux-media@vger.kernel.org Subject: Re: [PATCH] drm/i915/gt: fix unsigned integer to signed assignment In-Reply-To: <9a7b0e48-b00f-be11-7fc7-bc26719cbc1e@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20220216083849.91239-1-jiapeng.chong@linux.alibaba.com> <87h78z5gmp.fsf@intel.com> <9a7b0e48-b00f-be11-7fc7-bc26719cbc1e@linux.intel.com> Date: Wed, 16 Feb 2022 12:33:30 +0200 Message-ID: <87leyb3xtx.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 16 Feb 2022, Tvrtko Ursulin wrote: > On 16/02/2022 09:19, Ville Syrj=C3=A4l=C3=A4 wrote: >> On Wed, Feb 16, 2022 at 11:02:06AM +0200, Jani Nikula wrote: >>> On Wed, 16 Feb 2022, Jiapeng Chong wr= ote: >>>> Eliminate the follow smatch warning: >>>> >>>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:4640 >>>> guc_create_virtual() warn: assigning (-2) to unsigned variable >>>> 've->base.instance'. >>>> >>>> drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:4641 >>>> guc_create_virtual() warn: assigning (-2) to unsigned variable >>>> 've->base.uabi_instance'. >>>> >>>> Reported-by: Abaci Robot >>>> Signed-off-by: Jiapeng Chong >>> >>> The report seems to be valid, but I don't think this is the fix. >>> >>> Where do we even check for invalid instance/uabi_instance in code? >>=20 >> The whole thing seems rather poorly documented as there's a matching >> uabi struct with __u16's and the negative values are defined right >> there in the uapi header as well. > > Negative ones are exception values to be used in conjunction with the vir= tual engine uapi (see "DOC: Virtual Engine uAPI" and also comment next to I= 915_CONTEXT_PARAM_ENGINES). > > AFAIK assigning negative int to unsigned int is defined and fine. > > Compiler does warn on comparisons which is why we have: > > ./gem/i915_gem_busy.c: if (id =3D=3D (u16)I915_ENGINE_CLASS_INVALID) > ./gem/i915_gem_busy.c: if (id =3D=3D (u16)I915_ENGINE_CLASS_INVALID) > ./gem/i915_gem_context.c: if (ci.engine_class =3D=3D (u16)I= 915_ENGINE_CLASS_INVALID && > ./gem/i915_gem_context.c: ci.engine_instance =3D=3D (u1= 6)I915_ENGINE_CLASS_INVALID_NONE) > > So I think no action needed here. We never check instance or uabi_instance members against I915_ENGINE_CLASS_INVALID_VIRTUAL anywhere. BR, Jani. > > Regards, > > Tvrtko >=20=20=20 >>> >>> BR, >>> Jani. >>> >>> >>>> --- >>>> drivers/gpu/drm/i915/gt/intel_engine_types.h | 4 ++-- >>>> 1 file changed, 2 insertions(+), 2 deletions(-) >>>> >>>> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_types.h b/drivers/gp= u/drm/i915/gt/intel_engine_types.h >>>> index 36365bdbe1ee..dc7cc06c68e7 100644 >>>> --- a/drivers/gpu/drm/i915/gt/intel_engine_types.h >>>> +++ b/drivers/gpu/drm/i915/gt/intel_engine_types.h >>>> @@ -328,10 +328,10 @@ struct intel_engine_cs { >>>> intel_engine_mask_t logical_mask; >>>>=20=20=20 >>>> u8 class; >>>> - u8 instance; >>>> + s8 instance; >>>>=20=20=20 >>>> u16 uabi_class; >>>> - u16 uabi_instance; >>>> + s16 uabi_instance; >>>>=20=20=20 >>>> u32 uabi_capabilities; >>>> u32 context_size; >>> >>> --=20 >>> Jani Nikula, Intel Open Source Graphics Center >>=20 --=20 Jani Nikula, Intel Open Source Graphics Center