linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] MIPS: Restore CONFIG_CAVIUM_RESERVE32
@ 2022-07-25  9:17 Alexander A Sverdlin
  2022-07-25  9:17 ` [PATCH 1/2] MIPS: Introduce CAVIUM_RESERVE32 Kconfig option Alexander A Sverdlin
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Alexander A Sverdlin @ 2022-07-25  9:17 UTC (permalink / raw)
  To: linux-mips, Joe Perches
  Cc: Alexander Sverdlin, Thomas Bogendoerfer, Corey Minyard, linux-kernel

From: Alexander Sverdlin <alexander.sverdlin@nokia.com>

We have been using the option but the definition in the Kconfig has not
been upstreamed. Fix that.

Alexander Sverdlin (2):
  MIPS: Introduce CAVIUM_RESERVE32 Kconfig option
  Revert "MIPS: octeon: Remove vestiges of CONFIG_CAVIUM_RESERVE32"

 arch/mips/cavium-octeon/Kconfig                    | 12 +++++++
 arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c | 21 +++++++++---
 arch/mips/cavium-octeon/setup.c                    | 38 +++++++++++++++++++++-
 3 files changed, 66 insertions(+), 5 deletions(-)

-- 
2.10.2


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

* [PATCH 1/2] MIPS: Introduce CAVIUM_RESERVE32 Kconfig option
  2022-07-25  9:17 [PATCH 0/2] MIPS: Restore CONFIG_CAVIUM_RESERVE32 Alexander A Sverdlin
@ 2022-07-25  9:17 ` Alexander A Sverdlin
  2022-08-30  3:02   ` Yu Zhao
  2022-07-25  9:17 ` [PATCH 2/2] Revert "MIPS: octeon: Remove vestiges of CONFIG_CAVIUM_RESERVE32" Alexander A Sverdlin
  2022-07-30  9:02 ` [PATCH 0/2] MIPS: Restore CONFIG_CAVIUM_RESERVE32 Thomas Bogendoerfer
  2 siblings, 1 reply; 8+ messages in thread
From: Alexander A Sverdlin @ 2022-07-25  9:17 UTC (permalink / raw)
  To: linux-mips, Joe Perches
  Cc: Alexander Sverdlin, Thomas Bogendoerfer, Corey Minyard, linux-kernel

From: Alexander Sverdlin <alexander.sverdlin@nokia.com>

This options is used to reserve a shared memory region for user processes
to use for hardware memory buffers. The actual code to support the option
comes in the following patch.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
---
 arch/mips/cavium-octeon/Kconfig | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/mips/cavium-octeon/Kconfig b/arch/mips/cavium-octeon/Kconfig
index 4984e46..c1899f1 100644
--- a/arch/mips/cavium-octeon/Kconfig
+++ b/arch/mips/cavium-octeon/Kconfig
@@ -67,6 +67,18 @@ config CAVIUM_OCTEON_LOCK_L2_MEMCPY
 	help
 	  Lock the kernel's implementation of memcpy() into L2.
 
+config CAVIUM_RESERVE32
+	int "Memory to reserve for user processes shared region (MB)"
+	range 0 1536
+	default "0"
+	help
+	  Reserve a shared memory region for user processes to use for hardware
+	  memory buffers. This is required for 32bit applications to be able to
+	  send and receive packets directly. Applications access this memory by
+	  memory mapping /dev/mem for the addresses in /proc/octeon_info. For
+	  optimal performance with HugeTLBs, keep this size an even number of
+	  megabytes.
+
 config OCTEON_ILM
 	tristate "Module to measure interrupt latency using Octeon CIU Timer"
 	help
-- 
2.10.2


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

* [PATCH 2/2] Revert "MIPS: octeon: Remove vestiges of CONFIG_CAVIUM_RESERVE32"
  2022-07-25  9:17 [PATCH 0/2] MIPS: Restore CONFIG_CAVIUM_RESERVE32 Alexander A Sverdlin
  2022-07-25  9:17 ` [PATCH 1/2] MIPS: Introduce CAVIUM_RESERVE32 Kconfig option Alexander A Sverdlin
@ 2022-07-25  9:17 ` Alexander A Sverdlin
  2022-07-30 17:18   ` Joe Perches
  2022-07-30  9:02 ` [PATCH 0/2] MIPS: Restore CONFIG_CAVIUM_RESERVE32 Thomas Bogendoerfer
  2 siblings, 1 reply; 8+ messages in thread
From: Alexander A Sverdlin @ 2022-07-25  9:17 UTC (permalink / raw)
  To: linux-mips, Joe Perches
  Cc: Alexander Sverdlin, Thomas Bogendoerfer, Corey Minyard, linux-kernel

From: Alexander Sverdlin <alexander.sverdlin@nokia.com>

This reverts commit e98b461bb057aaea6fa766260788c08825213837.

We actually have been using the CONFIG_CAVIUM_RESERVE32 and previous patch
defined it in the corresponding Kconfig.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
---
 arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c | 21 +++++++++---
 arch/mips/cavium-octeon/setup.c                    | 38 +++++++++++++++++++++-
 2 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c b/arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c
index 20189e9..bf13e35 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c
@@ -57,14 +57,27 @@ EXPORT_SYMBOL_GPL(__cvmx_cmd_queue_state_ptr);
 static cvmx_cmd_queue_result_t __cvmx_cmd_queue_init_state_ptr(void)
 {
 	char *alloc_name = "cvmx_cmd_queues";
+#if defined(CONFIG_CAVIUM_RESERVE32) && CONFIG_CAVIUM_RESERVE32
+	extern uint64_t octeon_reserve32_memory;
+#endif
 
 	if (likely(__cvmx_cmd_queue_state_ptr))
 		return CVMX_CMD_QUEUE_SUCCESS;
 
-	__cvmx_cmd_queue_state_ptr =
-		cvmx_bootmem_alloc_named(sizeof(*__cvmx_cmd_queue_state_ptr),
-					 128,
-					 alloc_name);
+#if defined(CONFIG_CAVIUM_RESERVE32) && CONFIG_CAVIUM_RESERVE32
+	if (octeon_reserve32_memory)
+		__cvmx_cmd_queue_state_ptr =
+		    cvmx_bootmem_alloc_named_range(sizeof(*__cvmx_cmd_queue_state_ptr),
+						   octeon_reserve32_memory,
+						   octeon_reserve32_memory +
+						   (CONFIG_CAVIUM_RESERVE32 <<
+						    20) - 1, 128, alloc_name);
+	else
+#endif
+		__cvmx_cmd_queue_state_ptr =
+		    cvmx_bootmem_alloc_named(sizeof(*__cvmx_cmd_queue_state_ptr),
+					    128,
+					    alloc_name);
 	if (__cvmx_cmd_queue_state_ptr)
 		memset(__cvmx_cmd_queue_state_ptr, 0,
 		       sizeof(*__cvmx_cmd_queue_state_ptr));
diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
index 00bf269..cbd8320 100644
--- a/arch/mips/cavium-octeon/setup.c
+++ b/arch/mips/cavium-octeon/setup.c
@@ -284,6 +284,11 @@ void octeon_crash_smp_send_stop(void)
 
 #endif /* CONFIG_KEXEC */
 
+#ifdef CONFIG_CAVIUM_RESERVE32
+uint64_t octeon_reserve32_memory;
+EXPORT_SYMBOL(octeon_reserve32_memory);
+#endif
+
 #ifdef CONFIG_KEXEC
 /* crashkernel cmdline parameter is parsed _after_ memory setup
  * we also parse it here (workaround for EHB5200) */
@@ -661,7 +666,9 @@ void __init prom_init(void)
 	int i;
 	u64 t;
 	int argc;
-
+#ifdef CONFIG_CAVIUM_RESERVE32
+	int64_t addr = -1;
+#endif
 	/*
 	 * The bootloader passes a pointer to the boot descriptor in
 	 * $a3, this is available as fw_arg3.
@@ -776,6 +783,25 @@ void __init prom_init(void)
 		cvmx_write_csr(CVMX_LED_UDD_DATX(1), 0);
 		cvmx_write_csr(CVMX_LED_EN, 1);
 	}
+#ifdef CONFIG_CAVIUM_RESERVE32
+	/*
+	 * We need to temporarily allocate all memory in the reserve32
+	 * region. This makes sure the kernel doesn't allocate this
+	 * memory when it is getting memory from the
+	 * bootloader. Later, after the memory allocations are
+	 * complete, the reserve32 will be freed.
+	 *
+	 * Allocate memory for RESERVED32 aligned on 2MB boundary. This
+	 * is in case we later use hugetlb entries with it.
+	 */
+	addr = cvmx_bootmem_phy_named_block_alloc(CONFIG_CAVIUM_RESERVE32 << 20,
+						0, 0, 2 << 20,
+						"CAVIUM_RESERVE32", 0);
+	if (addr < 0)
+		pr_err("Failed to allocate CAVIUM_RESERVE32 memory area\n");
+	else
+		octeon_reserve32_memory = addr;
+#endif
 
 #ifdef CONFIG_CAVIUM_OCTEON_LOCK_L2
 	if (cvmx_read_csr(CVMX_L2D_FUS3) & (3ull << 34)) {
@@ -1053,6 +1079,16 @@ void __init plat_mem_setup(void)
 	cvmx_bootmem_unlock();
 #endif /* CONFIG_CRASH_DUMP */
 
+#ifdef CONFIG_CAVIUM_RESERVE32
+	/*
+	 * Now that we've allocated the kernel memory it is safe to
+	 * free the reserved region. We free it here so that builtin
+	 * drivers can use the memory.
+	 */
+	if (octeon_reserve32_memory)
+		cvmx_bootmem_free_named("CAVIUM_RESERVE32");
+#endif /* CONFIG_CAVIUM_RESERVE32 */
+
 	if (total == 0)
 		panic("Unable to allocate memory from "
 		      "cvmx_bootmem_phy_alloc");
-- 
2.10.2


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

* Re: [PATCH 0/2] MIPS: Restore CONFIG_CAVIUM_RESERVE32
  2022-07-25  9:17 [PATCH 0/2] MIPS: Restore CONFIG_CAVIUM_RESERVE32 Alexander A Sverdlin
  2022-07-25  9:17 ` [PATCH 1/2] MIPS: Introduce CAVIUM_RESERVE32 Kconfig option Alexander A Sverdlin
  2022-07-25  9:17 ` [PATCH 2/2] Revert "MIPS: octeon: Remove vestiges of CONFIG_CAVIUM_RESERVE32" Alexander A Sverdlin
@ 2022-07-30  9:02 ` Thomas Bogendoerfer
  2 siblings, 0 replies; 8+ messages in thread
From: Thomas Bogendoerfer @ 2022-07-30  9:02 UTC (permalink / raw)
  To: Alexander A Sverdlin; +Cc: linux-mips, Joe Perches, Corey Minyard, linux-kernel

On Mon, Jul 25, 2022 at 11:17:38AM +0200, Alexander A Sverdlin wrote:
> From: Alexander Sverdlin <alexander.sverdlin@nokia.com>
> 
> We have been using the option but the definition in the Kconfig has not
> been upstreamed. Fix that.
> 
> Alexander Sverdlin (2):
>   MIPS: Introduce CAVIUM_RESERVE32 Kconfig option
>   Revert "MIPS: octeon: Remove vestiges of CONFIG_CAVIUM_RESERVE32"
> 
>  arch/mips/cavium-octeon/Kconfig                    | 12 +++++++
>  arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c | 21 +++++++++---
>  arch/mips/cavium-octeon/setup.c                    | 38 +++++++++++++++++++++-
>  3 files changed, 66 insertions(+), 5 deletions(-)

series applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

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

* Re: [PATCH 2/2] Revert "MIPS: octeon: Remove vestiges of CONFIG_CAVIUM_RESERVE32"
  2022-07-25  9:17 ` [PATCH 2/2] Revert "MIPS: octeon: Remove vestiges of CONFIG_CAVIUM_RESERVE32" Alexander A Sverdlin
@ 2022-07-30 17:18   ` Joe Perches
  0 siblings, 0 replies; 8+ messages in thread
From: Joe Perches @ 2022-07-30 17:18 UTC (permalink / raw)
  To: Alexander A Sverdlin, linux-mips
  Cc: Thomas Bogendoerfer, Corey Minyard, linux-kernel

On Mon, 2022-07-25 at 11:17 +0200, Alexander A Sverdlin wrote:
> From: Alexander Sverdlin <alexander.sverdlin@nokia.com>
> 
> This reverts commit e98b461bb057aaea6fa766260788c08825213837.
> 
> We actually have been using the CONFIG_CAVIUM_RESERVE32 and previous patch
> defined it in the corresponding Kconfig.

Perhaps all of the uses of

#if defined(CONFIG_CAVIUM_RESERVE32)

should be

#if defined(CONFIG_CAVIUM_RESERVE32) && CONFIG_CAVIUM_RESERVE32

> diff --git a/arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c b/arch/mips/cavium-octeon/executive/cvmx-cmd-queue.c
[]
> @@ -57,14 +57,27 @@ EXPORT_SYMBOL_GPL(__cvmx_cmd_queue_state_ptr);
>  static cvmx_cmd_queue_result_t __cvmx_cmd_queue_init_state_ptr(void)
>  {
>  	char *alloc_name = "cvmx_cmd_queues";
> +#if defined(CONFIG_CAVIUM_RESERVE32) && CONFIG_CAVIUM_RESERVE32
> +	extern uint64_t octeon_reserve32_memory;
> +#endif

Like these

> +#if defined(CONFIG_CAVIUM_RESERVE32) && CONFIG_CAVIUM_RESERVE32
> +	if (octeon_reserve32_memory)
> +		__cvmx_cmd_queue_state_ptr =
> +		    cvmx_bootmem_alloc_named_range(sizeof(*__cvmx_cmd_queue_state_ptr),
> +						   octeon_reserve32_memory,
> +						   octeon_reserve32_memory +
> +						   (CONFIG_CAVIUM_RESERVE32 <<
> +						    20) - 1, 128, alloc_name);
> +	else
> +#endif
> +		__cvmx_cmd_queue_state_ptr =
> +		    cvmx_bootmem_alloc_named(sizeof(*__cvmx_cmd_queue_state_ptr),
> +					    128,
> +					    alloc_name);

[]

> diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c
[]
> @@ -284,6 +284,11 @@ void octeon_crash_smp_send_stop(void)
[]
> +#ifdef CONFIG_CAVIUM_RESERVE32

here.

> +uint64_t octeon_reserve32_memory;
> +EXPORT_SYMBOL(octeon_reserve32_memory);
> +#endif

[]

> @@ -661,7 +666,9 @@ void __init prom_init(void)
>  	int i;
>  	u64 t;
>  	int argc;
> -
> +#ifdef CONFIG_CAVIUM_RESERVE32
> +	int64_t addr = -1;

here

> +#endif
>  	/*
>  	 * The bootloader passes a pointer to the boot descriptor in
>  	 * $a3, this is available as fw_arg3.
> @@ -776,6 +783,25 @@ void __init prom_init(void)
>  		cvmx_write_csr(CVMX_LED_UDD_DATX(1), 0);
>  		cvmx_write_csr(CVMX_LED_EN, 1);
>  	}
> +#ifdef CONFIG_CAVIUM_RESERVE32

etc...


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

* Re: [PATCH 1/2] MIPS: Introduce CAVIUM_RESERVE32 Kconfig option
  2022-07-25  9:17 ` [PATCH 1/2] MIPS: Introduce CAVIUM_RESERVE32 Kconfig option Alexander A Sverdlin
@ 2022-08-30  3:02   ` Yu Zhao
  2022-09-05 18:50     ` Yu Zhao
  0 siblings, 1 reply; 8+ messages in thread
From: Yu Zhao @ 2022-08-30  3:02 UTC (permalink / raw)
  To: alexander.sverdlin; +Cc: cminyard, joe, linux-kernel, linux-mips, tsbogend

Hi,

This commit produces a bogus error message on systems that use the
default value. Please take a look.

Thanks.

  Linux version 6.0.0-rc1 (builder@buildhost) (mips64-openwrt-linux-musl-gcc (OpenWrt GCC 11.2.0 r19590-042d558536) 11.2.0, GNU ld (GNU Binutils) 2.37) #0 SMP Sun Jul 31 15:12:47 2022
  Failed to allocate CAVIUM_RESERVE32 memory area  <<<===
  Skipping L2 locking due to reduced L2 cache size
  CVMSEG size: 0 cache lines (0 bytes)
  printk: bootconsole [early0] enabled
  CPU0 revision is: 000d9301 (Cavium Octeon II)

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

* Re: [PATCH 1/2] MIPS: Introduce CAVIUM_RESERVE32 Kconfig option
  2022-08-30  3:02   ` Yu Zhao
@ 2022-09-05 18:50     ` Yu Zhao
  2022-09-06  7:55       ` Alexander Sverdlin
  0 siblings, 1 reply; 8+ messages in thread
From: Yu Zhao @ 2022-09-05 18:50 UTC (permalink / raw)
  To: alexander.sverdlin; +Cc: cminyard, joe, linux-kernel, linux-mips, tsbogend

Hi Alexander,

On Mon, Aug 29, 2022 at 9:03 PM Yu Zhao <yuzhao@google.com> wrote:
>
> Hi,
>
> This commit produces a bogus error message on systems that use the
> default value. Please take a look.
>
> Thanks.
>
>   Linux version 6.0.0-rc1 (builder@buildhost) (mips64-openwrt-linux-musl-gcc (OpenWrt GCC 11.2.0 r19590-042d558536) 11.2.0, GNU ld (GNU Binutils) 2.37) #0 SMP Sun Jul 31 15:12:47 2022
>   Failed to allocate CAVIUM_RESERVE32 memory area  <<<===
>   Skipping L2 locking due to reduced L2 cache size
>   CVMSEG size: 0 cache lines (0 bytes)
>   printk: bootconsole [early0] enabled
>   CPU0 revision is: 000d9301 (Cavium Octeon II)

Following up on this. Please take a look. Thanks.

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

* Re: [PATCH 1/2] MIPS: Introduce CAVIUM_RESERVE32 Kconfig option
  2022-09-05 18:50     ` Yu Zhao
@ 2022-09-06  7:55       ` Alexander Sverdlin
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander Sverdlin @ 2022-09-06  7:55 UTC (permalink / raw)
  To: Yu Zhao; +Cc: cminyard, joe, linux-kernel, linux-mips, tsbogend

Hello Yu,

On 05/09/2022 20:50, Yu Zhao wrote:
>> This commit produces a bogus error message on systems that use the
>> default value. Please take a look.
>>
>> Thanks.
>>
>>   Linux version 6.0.0-rc1 (builder@buildhost) (mips64-openwrt-linux-musl-gcc (OpenWrt GCC 11.2.0 r19590-042d558536) 11.2.0, GNU ld (GNU Binutils) 2.37) #0 SMP Sun Jul 31 15:12:47 2022
>>   Failed to allocate CAVIUM_RESERVE32 memory area  <<<===
>>   Skipping L2 locking due to reduced L2 cache size
>>   CVMSEG size: 0 cache lines (0 bytes)
>>   printk: bootconsole [early0] enabled
>>   CPU0 revision is: 000d9301 (Cavium Octeon II)
> Following up on this. Please take a look. Thanks.

thanks for following this up! I thought I've sent the patch a week ago, but seems something
went wrong... Nevertheless:
https://lore.kernel.org/linux-mips/20220906075253.28491-1-alexander.sverdlin@nokia.com/T/#u

-- 
Best regards,
Alexander Sverdlin.

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

end of thread, other threads:[~2022-09-06  7:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-25  9:17 [PATCH 0/2] MIPS: Restore CONFIG_CAVIUM_RESERVE32 Alexander A Sverdlin
2022-07-25  9:17 ` [PATCH 1/2] MIPS: Introduce CAVIUM_RESERVE32 Kconfig option Alexander A Sverdlin
2022-08-30  3:02   ` Yu Zhao
2022-09-05 18:50     ` Yu Zhao
2022-09-06  7:55       ` Alexander Sverdlin
2022-07-25  9:17 ` [PATCH 2/2] Revert "MIPS: octeon: Remove vestiges of CONFIG_CAVIUM_RESERVE32" Alexander A Sverdlin
2022-07-30 17:18   ` Joe Perches
2022-07-30  9:02 ` [PATCH 0/2] MIPS: Restore CONFIG_CAVIUM_RESERVE32 Thomas Bogendoerfer

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).