From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1E19210F29C for ; Mon, 17 Jan 2022 20:20:44 +0000 (UTC) Date: Mon, 17 Jan 2022 12:20:42 -0800 Message-ID: <85czkq9krp.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" In-Reply-To: <20220117085700.1723228-2-priyanka.dandamudi@intel.com> References: <20220117085700.1723228-1-priyanka.dandamudi@intel.com> <20220117085700.1723228-2-priyanka.dandamudi@intel.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Subject: Re: [igt-dev] [PATCH i-g-t v3 1/2] lib/igt_gt: Check for shared reset domain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" To: priyanka.dandamudi@intel.com Cc: igt-dev@lists.freedesktop.org, saurabhg.gupta@intel.com List-ID: On Mon, 17 Jan 2022 00:56:59 -0800, wrote: > > +bool has_shared_reset_domain(int fd, const intel_ctx_t *ctx) > +{ > + const struct intel_execution_engine2 *e; > + bool rcs0 = false; > + bool ccs0 = false; > + int ccs_count = 0; > + > + for_each_ctx_engine(fd, ctx, e) { > + if ((rcs0 && ccs0) || (ccs_count > 1)) > + break; > + else if (e->class == I915_ENGINE_CLASS_RENDER) > + rcs0 = true; > + else if (e->class == I915_ENGINE_CLASS_COMPUTE) { > + ccs0 = true; > + ccs_count++; > + } > + } > + return ((rcs0 && ccs0) || (ccs_count > 1)); > +} No need for bool, just use counts. Something like: bool has_shared_reset_domain(int fd, const intel_ctx_t *ctx) { const struct intel_execution_engine2 *e; int rcs = 0, ccs = 0; for_each_ctx_engine(fd, ctx, e) { if (e->class == I915_ENGINE_CLASS_RENDER) rcs++; else if (e->class == I915_ENGINE_CLASS_COMPUTE) ccs++; } return ((rcs && ccs) || (ccs >= 2)); } Hmm, this can just be: bool has_shared_reset_domain(int fd, const intel_ctx_t *ctx) { const struct intel_execution_engine2 *e; int count = 0; for_each_ctx_engine(fd, ctx, e) if (e->class == I915_ENGINE_CLASS_RENDER || e->class == I915_ENGINE_CLASS_COMPUTE) count++; return count >= 2; }