Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1912649lqo; Mon, 13 May 2024 02:07:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW8JrNoNO7n0aX7PISQt3KvEzyrnA3szhwMolLegVZR/LL2Vddirge6IzfeG9i3TsLh8hLi/SjiLYwY+Opz9yGZPNk2EQbLQJOgnep/bw== X-Google-Smtp-Source: AGHT+IFyzh/NXsSaoFfa5HabqxXhPDBl7JInYrZYreqwhpZe2qrHZ2CsthpdN+fiN+wW4FDv/RMp X-Received: by 2002:a50:9b42:0:b0:572:3b3c:754f with SMTP id 4fb4d7f45d1cf-5734d5c16f6mr9001155a12.4.1715591223209; Mon, 13 May 2024 02:07:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715591223; cv=pass; d=google.com; s=arc-20160816; b=I2lkn5pJmqqolgJT8Nk4/ryeDpUk7aFEHmq/W5bypoUXVhY/Za/YaRkdLWvNlSG4D0 EjWknaIxNdsNTzSl9ZvUGoYUDhVrTzX0zAqdCDqhkLSVocvFJ0/SkXoPvYhLf8r7xNgb Clrh66yWvqGe10jbZ18Z6QpElOF5Yu0YNO9SxL0RYyrCrCtWLQbUbIcwzu5MyWx1CFu8 61HZldnXtP0/oJOs1Oc+pYW7l+qgRzdwiLPfOPfd8RUCo+F6+inbA723J7sqNSvVhmu4 ti05/AHaHIBbcqeaxUtINfm5Q89Bc2oqBCkTmXNWD99/uC5xax8k7B509ayDhfukGLFK W+4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=organization:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ik3QbPmBNkPSPFmTBcUwf/rXm8iJTQX3RzuvB+SRjgw=; fh=7aVNKbGWYE2ZmG8rMtcqYJmu4E2W4+fQfILhAixbxKw=; b=Mw88rbCiyDrX0ftcTIClCRBz1ZRrnZNFnLr5aEZ2jquWr6OiNyy4Y4cvknXORRSaGU 8bENugN1TaHMHUR7Xej3bLmZznqfJzIf/6sSK71X2Orn7mwAhINpS1Uvw6hhVd8Fq20c 6xNL7l8asabbZs1OfY1HsAG46zfg2segYEUOCkWREFJ8h7/EoZ5PSMJNJlPNb6B4IEzt gbam7Mg+Yg9Pwwoyy0L04XmNEppN9DYYQ3l5FOYCziSEK2JqeBQ1JuTD9sBT4ji0cr/d d2TvcILmMfTHVumUwsxqKIC+lHp2p0xYKvtafdojGrdDXaPWTpQsGV4dmFCNWfdVSF5Z lo4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=X396QGVl; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-177372-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177372-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c36d78csi4708043a12.542.2024.05.13.02.07.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 02:07:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177372-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=X396QGVl; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-177372-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177372-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A0C821F22A7F for ; Mon, 13 May 2024 08:59:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EFB6E1487D2; Mon, 13 May 2024 08:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="X396QGVl" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 805432B9D1; Mon, 13 May 2024 08:59:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715590778; cv=none; b=eyQzHpXbT0b9UMbRHWn309NxzXoCgHK8STCcDPS6TO4WJUEpwZztmgVTvAOoQTJt307mMsat7L7WZYs6GRBN9KA3hspWarSIukEHmMQOuZcDyLyNjxujw+slBx/tJrPK9tHmA4CzYhSuSYv1IqeZGcx1xLaCDx1Ix/k0JGmtwf8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715590778; c=relaxed/simple; bh=GkcpnSXdP2QJe/nIK16ifPBaXDbWf1z8/BdrtfIYiB4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rtouipejJ/q8/BlJkof8Fj0dPLy6rm+2O0An9gWluhZR+mLhei+7LmH7rpvUydo17AOKi+M2syg3Uehkr1QQFEWEzn/4y808FFIX5Dmy8sswlKUGo8H7kABKP1WYXlY7uhHVDsF+2eEaVMD1eufuBKlPeE+c3kNE2Uefwnun89I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=X396QGVl; arc=none smtp.client-ip=198.175.65.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715590777; x=1747126777; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=GkcpnSXdP2QJe/nIK16ifPBaXDbWf1z8/BdrtfIYiB4=; b=X396QGVlWki4+XE0e5WT7nQThpZWED9yRuyf85sp7j3nfh/Zt8ccqV98 KJaCAqASXjY0GGE0pyXCE10/OxHRg9E0BRENXwar2g9sOeav4BhZJRW3Z K2oTtDz5X3vvR81qBLhTqdrHf618jrxv4gqBM069w00jb4KzHZWhZR3qx ovGSAa9e+nWaJ66RHTVY5txI58NJus9y4RzY/5W64XSf1dU0r3g/NGIZm KA1nvj6ZlK/VJ4WTnTYEeYWY9DJ7XGieM46uHOUb76xXZ5Rb2q6qzzYzm H6JdGCpdASIdcFuK2/HDBAwT+uwpHNnOJHPLJjPK4Nwckqopm9rjKEi9h w==; X-CSE-ConnectionGUID: O3zR/S6xRiOz5++e9k/+rg== X-CSE-MsgGUID: FXn5DOJQQ0u+dKLJYIIirA== X-IronPort-AV: E=McAfee;i="6600,9927,11071"; a="11348033" X-IronPort-AV: E=Sophos;i="6.08,157,1712646000"; d="scan'208";a="11348033" 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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