From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6A49CC433FE for ; Wed, 12 Oct 2022 23:46:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9EFC410E278; Wed, 12 Oct 2022 23:46:11 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 98AA310E278 for ; Wed, 12 Oct 2022 23:46:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1665618368; x=1697154368; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=hyeLk+KM25IY7brHy1m6MySZv2DZoty/hXU7qqCM4jI=; b=TzKie076mLmfeskjVEKznJXUFz2AViY1lowDF9szkaDZni7bF4B1CDDK TZlEahkybKqts46LBT1eY/iTCmJNfp7zw1+DAgGRpO26BF1mYkaAP0Mdd j3IXbwJSi9emy2MQ0Ehlw8DiObuqtVkWV+SIqnj8is9Ymo7qZKUuocGWG eUzB1R1OrKzyLVbk6rKF9dh+j/gVyQl2eqYW8aU6n7aG6Fzt91U2X+cgz o0/FpVOsmAuLEpjZD29cD8JyjF5tR6y5TDYxA7/wM3KYUqRfmSRIlgjwU MMDymThghcP3O+sBF1LWdpchJubaWf7hJLkfWCZV+zVmnwhRqijz2puBp g==; X-IronPort-AV: E=McAfee;i="6500,9779,10498"; a="284661114" X-IronPort-AV: E=Sophos;i="5.95,180,1661842800"; d="scan'208";a="284661114" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2022 16:46:08 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10498"; a="660115860" X-IronPort-AV: E=Sophos;i="5.95,180,1661842800"; d="scan'208";a="660115860" Received: from adixit-mobl.amr.corp.intel.com (HELO adixit-arch.intel.com) ([10.212.129.145]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2022 16:46:07 -0700 Date: Wed, 12 Oct 2022 16:46:07 -0700 Message-ID: <87sfjs8v28.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Umesh Nerlige Ramappa In-Reply-To: <20221012222739.27296-5-umesh.nerlige.ramappa@intel.com> References: <20221012222739.27296-1-umesh.nerlige.ramappa@intel.com> <20221012222739.27296-5-umesh.nerlige.ramappa@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Subject: Re: [Intel-gfx] [PATCH v4 04/16] drm/i915/perf: Determine gen12 oa ctx offset at runtime X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Wed, 12 Oct 2022 15:27:27 -0700, Umesh Nerlige Ramappa wrote: > > +static u32 oa_context_image_offset(struct intel_context *ce, u32 reg) > +{ > + u32 offset, len = (ce->engine->context_size - PAGE_SIZE) / 4; > + u32 *state = ce->lrc_reg_state; > + > + for (offset = 0; offset < len; ) { > + if (IS_MI_LRI_CMD(state[offset])) { > + /* > + * We expect reg-value pairs in MI_LRI command, so > + * MI_LRI_LEN() should be even, if not, issue a warning. > + */ > + drm_WARN_ON(&ce->engine->i915->drm, > + MI_LRI_LEN(state[offset]) & 0x1); > + > + if (oa_find_reg_in_lri(state, reg, &offset, len)) > + break; > + } else { > + offset++; > + } > + } > + > + /* > + * Note that the the reg value is written to 'offset + 1' location, so > + * ensure that the offset is less than (len - 1). > + */ > + return offset < len ? offset : U32_MAX; Should this then be 'offset < len - 1'? It is actually equivalent since length is even and we do idx += 2 in oa_find_reg_in_lri so 'offset < len' is the same as 'offset < len - 1' but since we mention (len - 1) in the comment maybe clearer to use 'offset < len - 1'?