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 D6908C25B10 for ; Mon, 13 May 2024 08:59:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E8DE10E207; Mon, 13 May 2024 08:59:37 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="BimMn69q"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 39CBC10E207 for ; Mon, 13 May 2024 08:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715590776; x=1747126776; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=GkcpnSXdP2QJe/nIK16ifPBaXDbWf1z8/BdrtfIYiB4=; b=BimMn69q2m5o+jyviM5oBvJoecfGdzpd3Hd52GWm19Au4rQdhkZD42X/ 66Z7lwYpO4UzCBBvdmYqJlil6GRk6lAo+zD4nUiUafc9ADjBQXIbzLUlZ ORiSMW/c/hatYE3g9nMCoC8sXoQ3DLlG3hEWEbWu2uEONmhWzuxQyZYaV nl/2TS3rnRbeROvw5QRF11VXSmvaTTNAz3Y5DQIZOnbdWpdNzE73n4FDH yXbpDHsCPM5xD4il9a8Zr9e/t3ziZ2HyMGA0XzOhIki+EQjMd+nwz5vHl OA071e71YSYIYndci7rpT01kb/BkDfr3W+ncg5yrlVpjGtSR7GRhLDCcg g==; X-CSE-ConnectionGUID: kzySkuuQQjuuhfjtqfBkYA== X-CSE-MsgGUID: 9LUWoYi3Q32JlDqrnB6cBQ== X-IronPort-AV: E=McAfee;i="6600,9927,11071"; a="11348042" X-IronPort-AV: E=Sophos;i="6.08,157,1712646000"; d="scan'208";a="11348042" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2024 01:59:36 -0700 X-CSE-ConnectionGUID: sBHxFiuaQr2d8aTgX+3YPQ== X-CSE-MsgGUID: THqMi0FFSxSmVvRr4ukQKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,157,1712646000"; d="scan'208";a="35149553" Received: from smile.fi.intel.com ([10.237.72.54]) by orviesa004.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2024 01:59:29 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1s6RWn-000000073rW-3Hnn; Mon, 13 May 2024 11:59:25 +0300 Date: Mon, 13 May 2024 11:59:25 +0300 From: Andy Shevchenko To: Devarsh Thakkar Cc: Jani Nikula , mchehab@kernel.org, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, benjamin.gaignard@collabora.com, sebastian.fricke@collabora.com, akpm@linux-foundation.org, gregkh@linuxfoundation.org, adobriyan@gmail.com, p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, dri-devel@lists.freedesktop.org, laurent.pinchart@ideasonboard.com, praneeth@ti.com, nm@ti.com, vigneshr@ti.com, a-bhatia1@ti.com, j-luthra@ti.com, b-brnich@ti.com, detheridge@ti.com, p-mantena@ti.com, vijayp@ti.com, andrzej.p@collabora.com, nicolas@ndufresne.ca Subject: Re: [PATCH v7 6/8] math.h Add macros to round to closest specified power of 2 Message-ID: References: <20240509183952.4064331-1-devarsht@ti.com> <87fruphf55.fsf@intel.com> <5ebcf480-81c6-4c2d-96e8-727d44f21ca9@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5ebcf480-81c6-4c2d-96e8-727d44f21ca9@ti.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Sat, May 11, 2024 at 11:11:14PM +0530, Devarsh Thakkar wrote: > On 10/05/24 20:45, Jani Nikula wrote: [...] > > Moreover, I think the naming of round_up() and round_down() should have > > reflected the fact that they operate on powers of 2. It's unfortunate > > that the difference to roundup() and rounddown() is just the underscore! > > That's just a trap. > > > > So let's perhaps not repeat the same with round_closest_up() and > > round_closest_down()? > > Yes the naming is inspired by existing macros i.e. round_up, round_down > (which round up/down to next pow of 2) and DIV_ROUND_CLOSEST (which > round the divided value to closest value) and there are already a lot of > users for these API's : > > linux-next git:(heads/next-20240509) ✗ grep -nr round_up drivers | wc > 730 4261 74775 > > linux-next git:(heads/next-20240509) ✗ grep -nr round_down drivers | wc > 226 1293 22194 > > linux-next git:(heads/next-20240509) ✗ grep -nr DIV_ROUND_CLOSEST > drivers | wc > 1207 7461 111822 Side note, discover `git grep ...`: it's much much faster on Git index, than classic one on a working copy. > so I thought to align with existing naming convention assuming > developers are already familiar with this. > > But if a wider consensus is to go with a newer naming convention then I > am open to it, although a challenge there would be to keep it short. For > e.g. this one is already 3 words, if we go with more explicit > "round_closest_up_pow_2" it looks quite long in my opinion :) . You need properly name the macros. Again, round_up() / roundup() and roundup_pow_of_two() are three _different_ macros, and it's not clear why you can't use one of them in your case. The patch that changes those to a new one are doubtful to begin with. I.e. need a careful review on the arithmetics side of the change including HW capabilities of handling "closest" results. -- With Best Regards, Andy Shevchenko