From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jani Nikula Subject: Re: [PATCH 02/13] drm/i915: Implement command buffer parsing logic Date: Fri, 07 Feb 2014 15:58:46 +0200 Message-ID: <8761or10tl.fsf@intel.com> References: <1385484699-51596-1-git-send-email-bradley.d.volkin@intel.com> <1391032514-19136-1-git-send-email-bradley.d.volkin@intel.com> <1391032514-19136-3-git-send-email-bradley.d.volkin@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 5062410579C for ; Fri, 7 Feb 2014 05:55:04 -0800 (PST) In-Reply-To: <1391032514-19136-3-git-send-email-bradley.d.volkin@intel.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: bradley.d.volkin@intel.com, intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Wed, 29 Jan 2014, bradley.d.volkin@intel.com wrote: > +static int valid_reg(const u32 *table, int count, u32 addr) > +{ > + if (table && count != 0) { > + int i; > + > + for (i = 0; i < count; i++) { > + if (table[i] == addr) > + return 1; > + } > + } You go to great lengths to validate the register tables are sorted, but in the end you don't take advantage of this fact by bailing out early if the lookup goes past the addr. Is this optimization the main reason for having the tables sorted, or are there other reasons too (I couldn't find any)? I'm beginning to wonder if this is a premature optimization that adds extra code. For master restricted registers you will always scan the regular reg table completely first. Perhaps a better option would be to have all registers in the same table, with a separate master flag, ordered by how frequently they are expected to be used. We do want to optimize for the happy day scenario. But maybe it's too early to tell. I'm inclined to ripping out the sort requirement and check, if the sole purpose is optimization, for simplicity's sake. BR, Jani. -- Jani Nikula, Intel Open Source Technology Center