All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/3] regmap: Drop never (properly) worked 64-bit support
@ 2023-06-22 18:36 Andy Shevchenko
  2023-06-22 18:36 ` [PATCH v1 1/3] regmap: Revert "add 64-bit mode support" and Co Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Andy Shevchenko @ 2023-06-22 18:36 UTC (permalink / raw)
  To: Mark Brown, Andy Shevchenko, linux-kernel
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Linus Walleij

regmap API internally operates on unsigned int values for the register
offsets and data. The commit back in 2015 that introduces 64-bit
excerpts in the code made a false impression that it works. Not really.

Consider two things:
 1/ register offset
 2/ data

For the first one is very rarely we need (except probably an MMIO case)
it. Even though, it won't work due to 32-bit limitations of the base offset.
Considering, let's say, 4 bytes stride the current implementation may
cover 36-bit of address space _only_. And 37-bit for the 8 bytes stride.

For the second one it's obviously that we want _all_ bits to be covered
in the data (otherwise what's the point?) and unsigned int gives us
only 32-bits.

With all this, revert all 64-bit excerpts from regmap API to avoid
false impressions and new code that never works.

Note, there are no users with such sizes in the kernel.

Andy Shevchenko (3):
  regmap: Revert "add 64-bit mode support" and Co.
  regmap: cache: Revert "Add 64-bit mode support"
  regmap: mmio: Remove unused 64-bit support code

 drivers/base/regmap/regcache.c    |  15 ----
 drivers/base/regmap/regmap-mmio.c |  24 ------
 drivers/base/regmap/regmap.c      | 122 ------------------------------
 3 files changed, 161 deletions(-)

-- 
2.40.0.1.gaa8946217a0b


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v1 1/3] regmap: Revert "add 64-bit mode support" and Co.
  2023-06-22 18:36 [PATCH v1 0/3] regmap: Drop never (properly) worked 64-bit support Andy Shevchenko
@ 2023-06-22 18:36 ` Andy Shevchenko
  2023-06-22 18:36 ` [PATCH v1 2/3] regmap: cache: Revert "Add 64-bit mode support" Andy Shevchenko
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2023-06-22 18:36 UTC (permalink / raw)
  To: Mark Brown, Andy Shevchenko, linux-kernel
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Linus Walleij

With unsigned int type we never ever can pass 64-bit value.
Remove never properly worked code.

Note, there are no users in kernel for this size of register
offsets or data.

This reverts commit afcc00b91f1865f6d0bbdb687dd642ce8a3c3c9e.

Also revert other 64-bit code excerpts in the regmap implementation
that had been induced by the false impression made by the above
mentioned change that there is a support of that data size.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/regmap/regmap.c | 122 -----------------------------------
 1 file changed, 122 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 89a7f1c459c1..8b37451fa931 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -311,26 +311,6 @@ static void regmap_format_32_native(void *buf, unsigned int val,
 	memcpy(buf, &v, sizeof(v));
 }
 
-#ifdef CONFIG_64BIT
-static void regmap_format_64_be(void *buf, unsigned int val, unsigned int shift)
-{
-	put_unaligned_be64((u64) val << shift, buf);
-}
-
-static void regmap_format_64_le(void *buf, unsigned int val, unsigned int shift)
-{
-	put_unaligned_le64((u64) val << shift, buf);
-}
-
-static void regmap_format_64_native(void *buf, unsigned int val,
-				    unsigned int shift)
-{
-	u64 v = (u64) val << shift;
-
-	memcpy(buf, &v, sizeof(v));
-}
-#endif
-
 static void regmap_parse_inplace_noop(void *buf)
 {
 }
@@ -411,40 +391,6 @@ static unsigned int regmap_parse_32_native(const void *buf)
 	return v;
 }
 
-#ifdef CONFIG_64BIT
-static unsigned int regmap_parse_64_be(const void *buf)
-{
-	return get_unaligned_be64(buf);
-}
-
-static unsigned int regmap_parse_64_le(const void *buf)
-{
-	return get_unaligned_le64(buf);
-}
-
-static void regmap_parse_64_be_inplace(void *buf)
-{
-	u64 v =  get_unaligned_be64(buf);
-
-	memcpy(buf, &v, sizeof(v));
-}
-
-static void regmap_parse_64_le_inplace(void *buf)
-{
-	u64 v = get_unaligned_le64(buf);
-
-	memcpy(buf, &v, sizeof(v));
-}
-
-static unsigned int regmap_parse_64_native(const void *buf)
-{
-	u64 v;
-
-	memcpy(&v, buf, sizeof(v));
-	return v;
-}
-#endif
-
 static void regmap_lock_hwlock(void *__map)
 {
 	struct regmap *map = __map;
@@ -1005,24 +951,6 @@ struct regmap *__regmap_init(struct device *dev,
 		}
 		break;
 
-#ifdef CONFIG_64BIT
-	case 64:
-		switch (reg_endian) {
-		case REGMAP_ENDIAN_BIG:
-			map->format.format_reg = regmap_format_64_be;
-			break;
-		case REGMAP_ENDIAN_LITTLE:
-			map->format.format_reg = regmap_format_64_le;
-			break;
-		case REGMAP_ENDIAN_NATIVE:
-			map->format.format_reg = regmap_format_64_native;
-			break;
-		default:
-			goto err_hwlock;
-		}
-		break;
-#endif
-
 	default:
 		goto err_hwlock;
 	}
@@ -1086,28 +1014,6 @@ struct regmap *__regmap_init(struct device *dev,
 			goto err_hwlock;
 		}
 		break;
-#ifdef CONFIG_64BIT
-	case 64:
-		switch (val_endian) {
-		case REGMAP_ENDIAN_BIG:
-			map->format.format_val = regmap_format_64_be;
-			map->format.parse_val = regmap_parse_64_be;
-			map->format.parse_inplace = regmap_parse_64_be_inplace;
-			break;
-		case REGMAP_ENDIAN_LITTLE:
-			map->format.format_val = regmap_format_64_le;
-			map->format.parse_val = regmap_parse_64_le;
-			map->format.parse_inplace = regmap_parse_64_le_inplace;
-			break;
-		case REGMAP_ENDIAN_NATIVE:
-			map->format.format_val = regmap_format_64_native;
-			map->format.parse_val = regmap_parse_64_native;
-			break;
-		default:
-			goto err_hwlock;
-		}
-		break;
-#endif
 	}
 
 	if (map->format.format_write) {
@@ -2160,9 +2066,6 @@ static int regmap_noinc_readwrite(struct regmap *map, unsigned int reg,
 	u8 *u8p;
 	u16 *u16p;
 	u32 *u32p;
-#ifdef CONFIG_64BIT
-	u64 *u64p;
-#endif
 	int ret;
 	int i;
 
@@ -2182,13 +2085,6 @@ static int regmap_noinc_readwrite(struct regmap *map, unsigned int reg,
 		if (write)
 			lastval = (unsigned int)u32p[val_count - 1];
 		break;
-#ifdef CONFIG_64BIT
-	case 8:
-		u64p = val;
-		if (write)
-			lastval = (unsigned int)u64p[val_count - 1];
-		break;
-#endif
 	default:
 		return -EINVAL;
 	}
@@ -2226,11 +2122,6 @@ static int regmap_noinc_readwrite(struct regmap *map, unsigned int reg,
 			case 4:
 				pr_cont("%x", u32p[i]);
 				break;
-#ifdef CONFIG_64BIT
-			case 8:
-				pr_cont("%llx", u64p[i]);
-				break;
-#endif
 			default:
 				break;
 			}
@@ -2438,11 +2329,6 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
 			case 4:
 				ival = *(u32 *)(val + (i * val_bytes));
 				break;
-#ifdef CONFIG_64BIT
-			case 8:
-				ival = *(u64 *)(val + (i * val_bytes));
-				break;
-#endif
 			default:
 				ret = -EINVAL;
 				goto out;
@@ -3207,9 +3093,6 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
 		for (i = 0; i < val_count * val_bytes; i += val_bytes)
 			map->format.parse_inplace(val + i);
 	} else {
-#ifdef CONFIG_64BIT
-		u64 *u64 = val;
-#endif
 		u32 *u32 = val;
 		u16 *u16 = val;
 		u8 *u8 = val;
@@ -3225,11 +3108,6 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val,
 				goto out;
 
 			switch (map->format.val_bytes) {
-#ifdef CONFIG_64BIT
-			case 8:
-				u64[i] = ival;
-				break;
-#endif
 			case 4:
 				u32[i] = ival;
 				break;
-- 
2.40.0.1.gaa8946217a0b


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v1 2/3] regmap: cache: Revert "Add 64-bit mode support"
  2023-06-22 18:36 [PATCH v1 0/3] regmap: Drop never (properly) worked 64-bit support Andy Shevchenko
  2023-06-22 18:36 ` [PATCH v1 1/3] regmap: Revert "add 64-bit mode support" and Co Andy Shevchenko
@ 2023-06-22 18:36 ` Andy Shevchenko
  2023-06-22 18:36 ` [PATCH v1 3/3] regmap: mmio: Remove unused 64-bit support code Andy Shevchenko
  2023-07-12 11:47 ` [PATCH v1 0/3] regmap: Drop never (properly) worked 64-bit support Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2023-06-22 18:36 UTC (permalink / raw)
  To: Mark Brown, Andy Shevchenko, linux-kernel
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Linus Walleij

There is no support for 64-bit data size in regmap, so
there is no point to have it in regmap cache.

This reverts commit 8b7663de6e2bfe3c40e1846e1c4625f33d138757.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/regmap/regcache.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index 28bc3ae9458a..156490ab7f34 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -590,14 +590,6 @@ void regcache_set_val(struct regmap *map, void *base, unsigned int idx,
 		cache[idx] = val;
 		break;
 	}
-#ifdef CONFIG_64BIT
-	case 8: {
-		u64 *cache = base;
-
-		cache[idx] = val;
-		break;
-	}
-#endif
 	default:
 		BUG();
 	}
@@ -630,13 +622,6 @@ unsigned int regcache_get_val(struct regmap *map, const void *base,
 
 		return cache[idx];
 	}
-#ifdef CONFIG_64BIT
-	case 8: {
-		const u64 *cache = base;
-
-		return cache[idx];
-	}
-#endif
 	default:
 		BUG();
 	}
-- 
2.40.0.1.gaa8946217a0b


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v1 3/3] regmap: mmio: Remove unused 64-bit support code
  2023-06-22 18:36 [PATCH v1 0/3] regmap: Drop never (properly) worked 64-bit support Andy Shevchenko
  2023-06-22 18:36 ` [PATCH v1 1/3] regmap: Revert "add 64-bit mode support" and Co Andy Shevchenko
  2023-06-22 18:36 ` [PATCH v1 2/3] regmap: cache: Revert "Add 64-bit mode support" Andy Shevchenko
@ 2023-06-22 18:36 ` Andy Shevchenko
  2023-07-12 11:47 ` [PATCH v1 0/3] regmap: Drop never (properly) worked 64-bit support Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2023-06-22 18:36 UTC (permalink / raw)
  To: Mark Brown, Andy Shevchenko, linux-kernel
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Linus Walleij

regmap API does not support 64-bit data size, so
there is no point to have it in regmap MMIO.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/base/regmap/regmap-mmio.c | 24 ------------------------
 1 file changed, 24 deletions(-)

diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c
index 8132b5c101c4..99d7fd85ca7d 100644
--- a/drivers/base/regmap/regmap-mmio.c
+++ b/drivers/base/regmap/regmap-mmio.c
@@ -202,15 +202,6 @@ static int regmap_mmio_noinc_write(void *context, unsigned int reg,
 				writel(swab32(valp[i]), ctx->regs + reg);
 			goto out_clk;
 		}
-#ifdef CONFIG_64BIT
-		case 8:
-		{
-			const u64 *valp = (const u64 *)val;
-			for (i = 0; i < val_count; i++)
-				writeq(swab64(valp[i]), ctx->regs + reg);
-			goto out_clk;
-		}
-#endif
 		default:
 			ret = -EINVAL;
 			goto out_clk;
@@ -227,11 +218,6 @@ static int regmap_mmio_noinc_write(void *context, unsigned int reg,
 	case 4:
 		writesl(ctx->regs + reg, (const u32 *)val, val_count);
 		break;
-#ifdef CONFIG_64BIT
-	case 8:
-		writesq(ctx->regs + reg, (const u64 *)val, val_count);
-		break;
-#endif
 	default:
 		ret = -EINVAL;
 		break;
@@ -363,11 +349,6 @@ static int regmap_mmio_noinc_read(void *context, unsigned int reg,
 	case 4:
 		readsl(ctx->regs + reg, (u32 *)val, val_count);
 		break;
-#ifdef CONFIG_64BIT
-	case 8:
-		readsq(ctx->regs + reg, (u64 *)val, val_count);
-		break;
-#endif
 	default:
 		ret = -EINVAL;
 		goto out_clk;
@@ -387,11 +368,6 @@ static int regmap_mmio_noinc_read(void *context, unsigned int reg,
 		case 4:
 			swab32_array(val, val_count);
 			break;
-#ifdef CONFIG_64BIT
-		case 8:
-			swab64_array(val, val_count);
-			break;
-#endif
 		default:
 			ret = -EINVAL;
 			break;
-- 
2.40.0.1.gaa8946217a0b


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 0/3] regmap: Drop never (properly) worked 64-bit support
  2023-06-22 18:36 [PATCH v1 0/3] regmap: Drop never (properly) worked 64-bit support Andy Shevchenko
                   ` (2 preceding siblings ...)
  2023-06-22 18:36 ` [PATCH v1 3/3] regmap: mmio: Remove unused 64-bit support code Andy Shevchenko
@ 2023-07-12 11:47 ` Mark Brown
  3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2023-07-12 11:47 UTC (permalink / raw)
  To: linux-kernel, Andy Shevchenko
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Linus Walleij

On Thu, 22 Jun 2023 21:36:10 +0300, Andy Shevchenko wrote:
> regmap API internally operates on unsigned int values for the register
> offsets and data. The commit back in 2015 that introduces 64-bit
> excerpts in the code made a false impression that it works. Not really.
> 
> Consider two things:
>  1/ register offset
>  2/ data
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/3] regmap: Revert "add 64-bit mode support" and Co.
      commit: 1425bdd7ef88631d0623ce3d0b8c89d8a65815d2
[2/3] regmap: cache: Revert "Add 64-bit mode support"
      commit: 039fd2e4134b7b880ba83f40a136df440047594a
[3/3] regmap: mmio: Remove unused 64-bit support code
      commit: 875403a7b524e9523e49dd32662adbc3e48cc12a

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-07-12 11:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-22 18:36 [PATCH v1 0/3] regmap: Drop never (properly) worked 64-bit support Andy Shevchenko
2023-06-22 18:36 ` [PATCH v1 1/3] regmap: Revert "add 64-bit mode support" and Co Andy Shevchenko
2023-06-22 18:36 ` [PATCH v1 2/3] regmap: cache: Revert "Add 64-bit mode support" Andy Shevchenko
2023-06-22 18:36 ` [PATCH v1 3/3] regmap: mmio: Remove unused 64-bit support code Andy Shevchenko
2023-07-12 11:47 ` [PATCH v1 0/3] regmap: Drop never (properly) worked 64-bit support Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.