linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] regmap: Drop CONFIG_64BIT checks from core
@ 2019-06-25 23:31 Marek Vasut
  2019-06-26 11:15 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Marek Vasut @ 2019-06-25 23:31 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marek Vasut, Rafael J . Wysocki, Mark Brown

Drop the CONFIG_64BIT checks from core regmap code, as it is well
possible to access e.g. an SPI device with 64bit registers from a
32bit CPU. The CONFIG_64BIT checks are still left in place in the
regmap mmio code however.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
---
 drivers/base/regmap/regcache.c |  4 ----
 drivers/base/regmap/regmap.c   | 14 --------------
 2 files changed, 18 deletions(-)

diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c
index a93cafd7be4f..e443d9de3f7e 100644
--- a/drivers/base/regmap/regcache.c
+++ b/drivers/base/regmap/regcache.c
@@ -577,14 +577,12 @@ bool 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();
 	}
@@ -618,13 +616,11 @@ 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();
 	}
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 19f57ccfbe1d..7da9dbb98d8a 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -298,7 +298,6 @@ static void regmap_format_32_native(void *buf, unsigned int val,
 	*(u32 *)buf = val << shift;
 }
 
-#ifdef CONFIG_64BIT
 static void regmap_format_64_be(void *buf, unsigned int val, unsigned int shift)
 {
 	__be64 *b = buf;
@@ -318,7 +317,6 @@ static void regmap_format_64_native(void *buf, unsigned int val,
 {
 	*(u64 *)buf = (u64)val << shift;
 }
-#endif
 
 static void regmap_parse_inplace_noop(void *buf)
 {
@@ -407,7 +405,6 @@ static unsigned int regmap_parse_32_native(const void *buf)
 	return *(u32 *)buf;
 }
 
-#ifdef CONFIG_64BIT
 static unsigned int regmap_parse_64_be(const void *buf)
 {
 	const __be64 *b = buf;
@@ -440,7 +437,6 @@ static unsigned int regmap_parse_64_native(const void *buf)
 {
 	return *(u64 *)buf;
 }
-#endif
 
 static void regmap_lock_hwlock(void *__map)
 {
@@ -921,7 +917,6 @@ struct regmap *__regmap_init(struct device *dev,
 		}
 		break;
 
-#ifdef CONFIG_64BIT
 	case 64:
 		switch (reg_endian) {
 		case REGMAP_ENDIAN_BIG:
@@ -937,7 +932,6 @@ struct regmap *__regmap_init(struct device *dev,
 			goto err_hwlock;
 		}
 		break;
-#endif
 
 	default:
 		goto err_hwlock;
@@ -998,7 +992,6 @@ struct regmap *__regmap_init(struct device *dev,
 			goto err_hwlock;
 		}
 		break;
-#ifdef CONFIG_64BIT
 	case 64:
 		switch (val_endian) {
 		case REGMAP_ENDIAN_BIG:
@@ -1019,7 +1012,6 @@ struct regmap *__regmap_init(struct device *dev,
 			goto err_hwlock;
 		}
 		break;
-#endif
 	}
 
 	if (map->format.format_write) {
@@ -2081,11 +2073,9 @@ 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;
@@ -2809,9 +2799,7 @@ 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;
@@ -2827,11 +2815,9 @@ 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.20.1


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

* Re: [RFC][PATCH] regmap: Drop CONFIG_64BIT checks from core
  2019-06-25 23:31 [RFC][PATCH] regmap: Drop CONFIG_64BIT checks from core Marek Vasut
@ 2019-06-26 11:15 ` Mark Brown
  2019-06-26 11:20   ` Marek Vasut
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2019-06-26 11:15 UTC (permalink / raw)
  To: Marek Vasut; +Cc: linux-kernel, Rafael J . Wysocki

[-- Attachment #1: Type: text/plain, Size: 549 bytes --]

On Wed, Jun 26, 2019 at 01:31:16AM +0200, Marek Vasut wrote:
> Drop the CONFIG_64BIT checks from core regmap code, as it is well
> possible to access e.g. an SPI device with 64bit registers from a
> 32bit CPU. The CONFIG_64BIT checks are still left in place in the
> regmap mmio code however.

The issue with 8 bit registers was that we use unsigned long for
addresses and values and a 64 bit value won't fit in those on a 32 bit
system.  Some of the bulk APIs will work but things like individual
register writes and the caches will have problems.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [RFC][PATCH] regmap: Drop CONFIG_64BIT checks from core
  2019-06-26 11:15 ` Mark Brown
@ 2019-06-26 11:20   ` Marek Vasut
  2019-06-26 12:05     ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Marek Vasut @ 2019-06-26 11:20 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, Rafael J . Wysocki

On 6/26/19 1:15 PM, Mark Brown wrote:
> On Wed, Jun 26, 2019 at 01:31:16AM +0200, Marek Vasut wrote:
>> Drop the CONFIG_64BIT checks from core regmap code, as it is well
>> possible to access e.g. an SPI device with 64bit registers from a
>> 32bit CPU. The CONFIG_64BIT checks are still left in place in the
>> regmap mmio code however.
> 
> The issue with 8 bit

byte

> registers was that we use unsigned long for
> addresses and values and a 64 bit value won't fit in those on a 32 bit
> system.  Some of the bulk APIs will work but things like individual
> register writes and the caches will have problems.

Good thing I sent this as RFC, I realized that shortly after too.

So, what would be the suggestion here ?

-- 
Best regards,
Marek Vasut

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

* Re: [RFC][PATCH] regmap: Drop CONFIG_64BIT checks from core
  2019-06-26 11:20   ` Marek Vasut
@ 2019-06-26 12:05     ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2019-06-26 12:05 UTC (permalink / raw)
  To: Marek Vasut; +Cc: linux-kernel, Rafael J . Wysocki

[-- Attachment #1: Type: text/plain, Size: 881 bytes --]

On Wed, Jun 26, 2019 at 01:20:17PM +0200, Marek Vasut wrote:
> On 6/26/19 1:15 PM, Mark Brown wrote:

> > registers was that we use unsigned long for
> > addresses and values and a 64 bit value won't fit in those on a 32 bit
> > system.  Some of the bulk APIs will work but things like individual
> > register writes and the caches will have problems.

> Good thing I sent this as RFC, I realized that shortly after too.

> So, what would be the suggestion here ?

I think if I had any really good ideas I'd have done it at the time :/
Converting to unsigned long long is going to hurt performance for the
common case but it'd probably be what we need to do, I think we'd need
to have some sort of preprocessor fun and build two copies of the code
with a 64 bit clean version available for devices that need it which is
ugly but bleh.  It's how we handle similar issues with zlib.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2019-06-26 12:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-25 23:31 [RFC][PATCH] regmap: Drop CONFIG_64BIT checks from core Marek Vasut
2019-06-26 11:15 ` Mark Brown
2019-06-26 11:20   ` Marek Vasut
2019-06-26 12:05     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).