Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp684544pxb; Wed, 16 Feb 2022 01:59:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyAMpVHlda1T4+S9hdZU9CSr/1SDBYE7PH/7fF/qXZskDFDh6TnYdcLiwZGjkGTjW3qtvq4 X-Received: by 2002:a05:6a00:2313:b0:4e0:ffa7:bbe0 with SMTP id h19-20020a056a00231300b004e0ffa7bbe0mr2250479pfh.53.1645005555344; Wed, 16 Feb 2022 01:59:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645005555; cv=none; d=google.com; s=arc-20160816; b=0ysC5BmoKtAoUWToIEzK4Suqdw6KK2/mRSrK/T+KLtHDx41RE1j8om3jvQcbAd7z6D UVQibS3vHqTYyqWZunad+zLbXwUwKOAgZ9Y1WiuU0MwLtESTziTBM4RxVELIjas4BtqJ PYXhAR1nDsDFCpagboNraMYgzZXdOiG8/zy4VGxsPbhwaKLdv9YhIWvSKd2dchqxAyQL f3+7IVr1VBnufUhjTaM297tM3XfhPmMIY0cEdHTXkTEwqA25kMXkfZ+9enuPmm4fwOFK WYZaCBE/7aadZc04i4URlwgjMHWRVHdgWvkRx9jyQKKGHswTXJwD/ifqnbz6SiUteLNj VylA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=k5Oif1Cxmgtp+KuGOi4jtHhCVwgEObzhA61MIMjrwiE=; b=lVTnDIWjDkpNdzSbLktoPeT8dL06YG6JnOqo9x31V2B43fSFF98SbUwa6Cuq1uvG4q 31XqfTG3qqseDTymj0g/qQlCo1TPJTy1gg+SVk214IVkL/MAlyA0A2pgtaW3dUSndmyR VUukNVTnzv0SObFFP9phv2tEcrRXX6xjgiVSfaunJb+Y4y/g0rkmNV0mJaotW8vMkYYy 8W6J1rxMoIMhHIiGXmf64tRlf8N/sx4KmhqeUrrdw/rVZLACZUgvsIcS82FKsD0X19YB jrZqO1w3umwCQu0lIVmPJZjn5aTpwHvx4b/4Wi0nvyDCoMSY6Jg2Sx/NUAtsSUqfwILm CziA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="ZyMA/iOQ"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k2si8078695plc.588.2022.02.16.01.59.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 01:59:15 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="ZyMA/iOQ"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 70C072B68C7; Wed, 16 Feb 2022 01:59:08 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232593AbiBPJ7H (ORCPT + 99 others); Wed, 16 Feb 2022 04:59:07 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:45664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232024AbiBPJ7G (ORCPT ); Wed, 16 Feb 2022 04:59:06 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24A46271E25; Wed, 16 Feb 2022 01:58:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645005535; x=1676541535; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=2Nl47R+l/Dyorm/plhVMc/vkL37v28gUnjuXNQsPVTw=; b=ZyMA/iOQcyX/YLLW5mFjvLJVUSuyvEjB7i6xZLMGD+OpsBnAfIk3logl 7cfuUC7NSMX3FKCiPHm30t95S0I4hYBc3EY+valOzzlIMFalwKLtizF87 Excrbz1L04TrDM+IeVCKIOESD5wA6zpQT1N5cVlgD6qpD7P3t7i8eNovr ZE5Fv+o7yMZ5rNG1k1Ld5GwR5/zEqCvOnlLy5b+jkh7cdoCJdV+1a2ZYU bkIVzedXsqVhwUpPSFabDah2PDWyva+21uSXGtgRwwAtHECO3qxz8XozH W7QRxBChc9H2G+yKbwK150uKvMHwqZeNKV3q2cpTA6nosjhV9LpY7MdPk A==; X-IronPort-AV: E=McAfee;i="6200,9189,10259"; a="237971896" X-IronPort-AV: E=Sophos;i="5.88,373,1635231600"; d="scan'208";a="237971896" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2022 01:57:54 -0800 X-IronPort-AV: E=Sophos;i="5.88,373,1635231600"; d="scan'208";a="502952891" Received: from sphadnis-mobl1.amr.corp.intel.com (HELO [10.212.82.113]) ([10.212.82.113]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2022 01:57:52 -0800 Message-ID: <9a7b0e48-b00f-be11-7fc7-bc26719cbc1e@linux.intel.com> Date: Wed, 16 Feb 2022 09:57:49 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] drm/i915/gt: fix unsigned integer to signed assignment Content-Language: en-US To: =?UTF-8?B?VmlsbGUgU3lyasOkbMOk?= , Jani Nikula 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 References: <20220216083849.91239-1-jiapeng.chong@linux.alibaba.com> <87h78z5gmp.fsf@intel.com> From: Tvrtko Ursulin Organization: Intel Corporation UK Plc In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no 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 16/02/2022 09:19, Ville Syrjälä wrote: > On Wed, Feb 16, 2022 at 11:02:06AM +0200, Jani Nikula wrote: >> On Wed, 16 Feb 2022, Jiapeng Chong wrote: >>> 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? > > 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 virtual engine uapi (see "DOC: Virtual Engine uAPI" and also comment next to I915_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 == (u16)I915_ENGINE_CLASS_INVALID) ./gem/i915_gem_busy.c: if (id == (u16)I915_ENGINE_CLASS_INVALID) ./gem/i915_gem_context.c: if (ci.engine_class == (u16)I915_ENGINE_CLASS_INVALID && ./gem/i915_gem_context.c: ci.engine_instance == (u16)I915_ENGINE_CLASS_INVALID_NONE) So I think no action needed here. Regards, Tvrtko >> >> 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/gpu/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; >>> >>> u8 class; >>> - u8 instance; >>> + s8 instance; >>> >>> u16 uabi_class; >>> - u16 uabi_instance; >>> + s16 uabi_instance; >>> >>> u32 uabi_capabilities; >>> u32 context_size; >> >> -- >> Jani Nikula, Intel Open Source Graphics Center >