From nobody Sun Nov 24 06:10:50 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 397D427447 for ; Thu, 21 Nov 2024 10:58:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732186726; cv=none; b=Y6Ug2hYwPItkKq09X623rvy1sE3BsTSVV7SrWE6bFDlOTW5z6vb0Rx9+s0Gs/N9l2prCTgB/AkUuvDRGbgXBJEsKYk5bA02U1GHNwqEBFb4thj73N8GfFH1PTcjpNiImUA+Ze1eJ0ZzonS+BmTaDl8yRFUBkJTwExs4Aw9jsA5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732186726; c=relaxed/simple; bh=DiJr9F7ZvlRiG1g4l7rc4I2mcQHoRxGjdHwnfO15tcA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A9SpDDPsVMcO2J1ojAEWUtHuWzzE9ZoPZmzqwxTw53ZKsJUDVcSiYeRX+i4CbYhSyavcVL8PgfWnJ1NAkxrOMHsYGnq6tjX05qoLw7PZ0qfDhKv7KrhYDwE4upmUx9zE7hR3Nha7yT0G7xAXf7GpoR6gC0+X5WRuf3M6nqiqzRo= 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=aV/xTwmI; arc=none smtp.client-ip=192.198.163.10 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="aV/xTwmI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1732186725; x=1763722725; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DiJr9F7ZvlRiG1g4l7rc4I2mcQHoRxGjdHwnfO15tcA=; b=aV/xTwmI5403TxjGtOFySxVsM+UNkjhfhbYYQ7eMS/xV3FQDbmEwwfCG vvhRela/HWBJYcM8d30FlXw4sblozwQrUQoDGbRIGdn6b11ZK4aRLjTgB M2OjJpdJaR9FNxPGb6YGvDmHblosVfljJt0C49m6T9Hy5iu7WhIv7uPlQ Y9iZhLo0FiXK+kbuz0zh1f44RZFAxYRRNWI1pm0LXeVJ7N0p1WiZdEx10 i/lSmuMHQ12lhsKv+fJ/A3ujKT0QWLZH2ytUXUMr9Ces8lA21bb5RvbZ6 xUE/CpeWGgZy4fNshhD06z6GkdwOJYlChYNJ8LuIvq19gRXBw7VDAIwPN g==; X-CSE-ConnectionGUID: heP4OTHkRWiEgdKinZsiYw== X-CSE-MsgGUID: B/hos6DBQ9WZR2c4FJanSQ== X-IronPort-AV: E=McAfee;i="6700,10204,11262"; a="43687807" X-IronPort-AV: E=Sophos;i="6.12,172,1728975600"; d="scan'208";a="43687807" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Nov 2024 02:58:45 -0800 X-CSE-ConnectionGUID: 5/897DWJQI+aZte+TmtA3Q== X-CSE-MsgGUID: TSIQEdXdTzqHqTLp2LgDgQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,172,1728975600"; d="scan'208";a="90623761" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa009.fm.intel.com with ESMTP; 21 Nov 2024 02:58:42 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2CF8E18E; Thu, 21 Nov 2024 12:58:41 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Guenter Roeck , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andy Shevchenko Subject: [PATCH v1 1/3] regmap: cache: Use BITS_TO_BYTES() Date: Thu, 21 Nov 2024 12:57:21 +0200 Message-ID: <20241121105838.4073659-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20241121105838.4073659-1-andriy.shevchenko@linux.intel.com> References: <20241121105838.4073659-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" BITS_TO_BYTES() is the existing macro which takes care about full bytes that may fully hold the given amount of bits. Use it. Signed-off-by: Andy Shevchenko --- drivers/base/regmap/regcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index d3659ba3cc11..b1f8508c3966 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -154,7 +154,7 @@ int regcache_init(struct regmap *map, const struct regm= ap_config *config) map->num_reg_defaults =3D config->num_reg_defaults; map->num_reg_defaults_raw =3D config->num_reg_defaults_raw; map->reg_defaults_raw =3D config->reg_defaults_raw; - map->cache_word_size =3D DIV_ROUND_UP(config->val_bits, 8); + map->cache_word_size =3D BITS_TO_BYTES(config->val_bits); map->cache_size_raw =3D map->cache_word_size * config->num_reg_defaults_r= aw; =20 map->cache =3D NULL; --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Sun Nov 24 06:10:50 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 C5E3D1CB51C for ; Thu, 21 Nov 2024 10:58:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732186727; cv=none; b=TRCq7tP6/UFtWRV7pLtDETBIdCUAkmYh0GOP7/ukq2ocDp1rZKzceB1Ky6OmiR6e0w4qtTvisWfBAbisMC7peKdYrTCKm+Ld/MguvdyFJlG3zWU3r3FThQQrNrf9GgYmbUQL6V9rb5RvGcdyra5oUzmYsCLjNSXnBrQZPjWwjf8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732186727; c=relaxed/simple; bh=q72Gj/SUfA1k0CyWT9Qff/94SnUAmYWSI18iC2SIVqk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m2DvzrtGJ6hucX+XmJzEmT96IO0Vbh8fu9x/ATd+oRU+vu19mWv8jFvqy2WxT2p6YCy/xxbQE/wU0P+d86rLuHXhvEUvb/jk3q8GR1wrlmKI0MLZhaNvH1/TAq5viwizp/flExGWqW3zw6l8QpooKkjb5wio9DIi2gCqeG4v6N8= 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=iDitwnrS; arc=none smtp.client-ip=192.198.163.16 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iDitwnrS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1732186726; x=1763722726; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q72Gj/SUfA1k0CyWT9Qff/94SnUAmYWSI18iC2SIVqk=; b=iDitwnrSsvt9ojZ7uM5+qxMtOkObToWFKC4oJsEG1p98sNC8pZ/oYkmV PNjODm3mPKQLDvwR6tbUAVn2JcRb58OM2X6QRAQDk1nhZx53wUv9nB6b/ DSS5kJvcXuUzQ9kO6BCZG3mU6sUcLyae18Hv6gOUavzeCHUvuUmGzndhp VzzumoWe4HSSeALy9tC8fz2MD5NLM+FJaT2QgevHhf+EuLDjUFmsd/et0 F21Z/0xMb/LuQjBbYEsnRwvQfLIdGddFd/68nhnnJK5V8brBcG9Gbu/2N nc+RK5FbrfNE8RokSnqbwcbBQjOBeKz+5qAC8+/V6dacQRTduVq4wlHy+ g==; X-CSE-ConnectionGUID: l5VFPOBASQyNxJI7z4oN9w== X-CSE-MsgGUID: bvFXZKsrQAWL3lu+fJ1/Ig== X-IronPort-AV: E=McAfee;i="6700,10204,11262"; a="19882808" X-IronPort-AV: E=Sophos;i="6.12,172,1728975600"; d="scan'208";a="19882808" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Nov 2024 02:58:45 -0800 X-CSE-ConnectionGUID: OVNcQxKxTUGmS6uuj9IN5g== X-CSE-MsgGUID: cGy7OQZeTl6c2KIWOD8GPw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,172,1728975600"; d="scan'208";a="127744822" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 21 Nov 2024 02:58:43 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 3BD42380; Thu, 21 Nov 2024 12:58:41 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Guenter Roeck , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andy Shevchenko Subject: [PATCH v1 2/3] regmap: Use BITS_TO_BYTES() Date: Thu, 21 Nov 2024 12:57:22 +0200 Message-ID: <20241121105838.4073659-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20241121105838.4073659-1-andriy.shevchenko@linux.intel.com> References: <20241121105838.4073659-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" BITS_TO_BYTES() is the existing macro which takes care about full bytes that may fully hold the given amount of bits. Use it. Signed-off-by: Andy Shevchenko --- drivers/base/regmap/regmap.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 53131a7ede0a..d2944271022c 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -759,12 +759,11 @@ struct regmap *__regmap_init(struct device *dev, =20 map->reg_base =3D config->reg_base; =20 - map->format.reg_bytes =3D DIV_ROUND_UP(config->reg_bits, 8); + map->format.reg_bytes =3D BITS_TO_BYTES(config->reg_bits); map->format.pad_bytes =3D config->pad_bits / 8; map->format.reg_shift =3D config->reg_shift; - map->format.val_bytes =3D DIV_ROUND_UP(config->val_bits, 8); - map->format.buf_size =3D DIV_ROUND_UP(config->reg_bits + - config->val_bits + config->pad_bits, 8); + map->format.val_bytes =3D BITS_TO_BYTES(config->val_bits); + map->format.buf_size =3D BITS_TO_BYTES(config->reg_bits + config->val_bit= s + config->pad_bits); map->reg_shift =3D config->pad_bits % 8; if (config->reg_stride) map->reg_stride =3D config->reg_stride; --=20 2.43.0.rc1.1336.g36b5255a03ac From nobody Sun Nov 24 06:10:50 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 4AAA41CD1F6 for ; Thu, 21 Nov 2024 10:58:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732186728; cv=none; b=ihSw6A+kfUirwUGb9OCgsSCve83bz0Su7uv0iUhGIJT8Qwjv7NSeT8w8onhGpqUIgFzuKTYB3KAj1l9OM7SCPGoZIXTOBPJLdhVqtHFr60BGrSxA8Sb+sw8CGwwxJMzTpP7LV1T+Xt0hItvtV7rAN8H/b8LcRhJ3WR/qyKH5ndI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732186728; c=relaxed/simple; bh=UOShiaopThGZW3idfKE30w3RHaDOTrWaSt+rbaz4iMY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iLVkkKmXrLrk9rAnf72ruL6y7MboVxdeA8ZwZ1d0fvzEOBYkzLwJnom0w5Eu4Wu7YqFTq9y5ccjZIZW3LCuTgHzdSOw8+uIA0YqytBkM3g3Q4cD+AYIc0M92TmvUb1jhn+WTi6OqqlimlxS+pG3cHIe9yzyelvTvjYMTqPcNgMo= 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=Oxn1Bgoh; arc=none smtp.client-ip=192.198.163.16 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Oxn1Bgoh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1732186727; x=1763722727; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UOShiaopThGZW3idfKE30w3RHaDOTrWaSt+rbaz4iMY=; b=Oxn1BgohoxIPH7BdaJJPS5nXXLxjfN/YOAYnvndadvKYNnH46OEv/YEr xu3+HiWPhs5JgG/QOfA20U+CVc/CFY1H221hyIK0OZ4cjYN5n+Ryyoouc YSkHnR5DxZL017KhJ88F32p91sf/Er9ZCM6jMe+Pzqv5G5yaaLupxfvoI w8xX2H3+O0XO378Lg8FueBLRd+CfjGV7vsZEESeqvjrZ69S7TuuqXXoHe P4W7UtcUfMfesg+jj3QNGkFpfju5FIVOBtKMVoxS6UBrgIyxw2B+Q0+Bm KJdmYPJyFCmWOV1w+ClfXQAejUksXL5DcWe5nNu2rWplyeR9UEpE4aYtG g==; X-CSE-ConnectionGUID: DBzfk2sUQayouPrtInJ3ig== X-CSE-MsgGUID: cncVx5D0TCSZ6Y0Xr0B//A== X-IronPort-AV: E=McAfee;i="6700,10204,11262"; a="19882814" X-IronPort-AV: E=Sophos;i="6.12,172,1728975600"; d="scan'208";a="19882814" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Nov 2024 02:58:45 -0800 X-CSE-ConnectionGUID: tErbgRfSS+OfkAa64pv44A== X-CSE-MsgGUID: z7boQprvT3a8HRe9rjNd6w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,172,1728975600"; d="scan'208";a="127744823" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 21 Nov 2024 02:58:43 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 43CBE38C; Thu, 21 Nov 2024 12:58:41 +0200 (EET) From: Andy Shevchenko To: Mark Brown , Guenter Roeck , linux-kernel@vger.kernel.org, llvm@lists.linux.dev Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Andy Shevchenko Subject: [PATCH v1 3/3] regmap: place foo / 8 and foo % 8 closer to each other Date: Thu, 21 Nov 2024 12:57:23 +0200 Message-ID: <20241121105838.4073659-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.43.0.rc1.1336.g36b5255a03ac In-Reply-To: <20241121105838.4073659-1-andriy.shevchenko@linux.intel.com> References: <20241121105838.4073659-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On x86 the compiler (gcc (Debian 14.2.0-8) 14.2.0) may generate a better code if it sees division and modulo goes together. Function old new delta __regmap_init 3740 3732 -8 Total: Before=3D31159, After=3D31151, chg -0.03% clang (Debian clang version 18.1.8) on x86_64 still shows better code Function old new delta __regmap_init 3582 3579 -3 Total: Before=3D39854, After=3D39851, chg -0.01% Signed-off-by: Andy Shevchenko --- drivers/base/regmap/regmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index d2944271022c..4f8ec8528e34 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -758,13 +758,13 @@ struct regmap *__regmap_init(struct device *dev, map->alloc_flags =3D GFP_KERNEL; =20 map->reg_base =3D config->reg_base; + map->reg_shift =3D config->pad_bits % 8; =20 - map->format.reg_bytes =3D BITS_TO_BYTES(config->reg_bits); map->format.pad_bytes =3D config->pad_bits / 8; map->format.reg_shift =3D config->reg_shift; + map->format.reg_bytes =3D BITS_TO_BYTES(config->reg_bits); map->format.val_bytes =3D BITS_TO_BYTES(config->val_bits); map->format.buf_size =3D BITS_TO_BYTES(config->reg_bits + config->val_bit= s + config->pad_bits); - map->reg_shift =3D config->pad_bits % 8; if (config->reg_stride) map->reg_stride =3D config->reg_stride; else --=20 2.43.0.rc1.1336.g36b5255a03ac