lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200118205625.14532-2-ben.whitten@gmail.com>
Date:   Sat, 18 Jan 2020 20:56:25 +0000
From:   Ben Whitten <ben.whitten@...il.com>
To:     linux-kernel@...r.kernel.org
Cc:     afaerber@...e.de, Ben Whitten <ben.whitten@...il.com>,
        Mark Brown <broonie@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>
Subject: [PATCH v2 2/2] regmap: stop splitting writes to non incrementing registers

When writing to non incrementing registers we should not split
the writes in any way, writing in one transaction.

Signed-off-by: Ben Whitten <ben.whitten@...il.com>
---
 drivers/base/regmap/regmap.c | 38 +++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 59f911e57719..d0dbf0ffd70f 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1528,24 +1528,30 @@ static int _regmap_raw_write_impl(struct regmap *map, unsigned int reg,
 		int win_offset = (reg - range->range_min) % range->window_len;
 		int win_residue = range->window_len - win_offset;
 
-		/* If the write goes beyond the end of the window split it */
-		while (val_num > win_residue) {
-			dev_dbg(map->dev, "Writing window %d/%zu\n",
-				win_residue, val_len / map->format.val_bytes);
-			ret = _regmap_raw_write_impl(map, reg, val,
-						     win_residue *
-						     map->format.val_bytes);
-			if (ret != 0)
-				return ret;
+		if (!regmap_writeable_noinc(map, reg)) {
+			/* If the write goes beyond the end of the window
+			 * split it */
+			while (val_num > win_residue) {
+				dev_dbg(map->dev, "Writing window %d/%zu\n",
+					win_residue,
+					val_len / map->format.val_bytes);
+				ret = _regmap_raw_write_impl(map, reg, val,
+							     win_residue *
+							     map->format.val_bytes);
+				if (ret != 0)
+					return ret;
 
-			reg += win_residue;
-			val_num -= win_residue;
-			val += win_residue * map->format.val_bytes;
-			val_len -= win_residue * map->format.val_bytes;
+				reg += win_residue;
+				val_num -= win_residue;
+				val += win_residue * map->format.val_bytes;
+				val_len -= win_residue * map->format.val_bytes;
 
-			win_offset = (reg - range->range_min) %
-				range->window_len;
-			win_residue = range->window_len - win_offset;
+				win_offset = (reg - range->range_min) %
+					range->window_len;
+				win_residue = range->window_len - win_offset;
+			}
+		} else {
+			val_num = 1;
 		}
 
 		ret = _regmap_select_page(map, &reg, range, val_num);
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ