From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Volkin, Bradley D" Subject: Re: [RFC 05/22] drm/i915: Implement command parsing Date: Tue, 26 Nov 2013 09:38:55 -0800 Message-ID: <20131126173855.GA51974@vpg-ubuntu-bdvolkin> References: <1385484699-51596-1-git-send-email-bradley.d.volkin@intel.com> <1385484699-51596-6-git-send-email-bradley.d.volkin@intel.com> <20131126172932.GF16131@nuc-i3427.alporthouse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 41FC5FB59A for ; Tue, 26 Nov 2013 09:39:26 -0800 (PST) Content-Disposition: inline In-Reply-To: <20131126172932.GF16131@nuc-i3427.alporthouse.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org To: Chris Wilson Cc: "intel-gfx@lists.freedesktop.org" List-Id: intel-gfx@lists.freedesktop.org On Tue, Nov 26, 2013 at 09:29:32AM -0800, Chris Wilson wrote: > On Tue, Nov 26, 2013 at 08:51:22AM -0800, bradley.d.volkin@intel.com wrote: > > +static const struct drm_i915_cmd_descriptor* > > +find_cmd_in_table(const struct drm_i915_cmd_table *table, > > + u32 cmd_header) > > +{ > > + int i; > > + > > + for (i = 0; i < table->count; i++) { > > + const struct drm_i915_cmd_descriptor *desc = &table->table[i]; > > + u32 masked_cmd = desc->cmd.mask & cmd_header; > > + u32 masked_value = desc->cmd.value & desc->cmd.mask; > > + > > + if (masked_cmd == masked_value) > > + return desc; > > Maybe pre-sort the cmd table and use bsearch? And a runtime test on > module load to check that the table is sorted correctly. So far it doesn't look like the search is a bottleneck, but I've tried to keep the tables sorted so that we could easily switch to bsearch if needed. Would you prefer to just use bsearch from the start? I agree that the module load check makes sense if we do switch. > -Chris > > -- > Chris Wilson, Intel Open Source Technology Centre