cpukit/confdefs: Add CAN stack resource calculation

The CAN/CAN FD stack requires a worker task per configured queue.
Empirical profiling confirms the CAN worker task utilizes ~404 bytes
of stack space on 32-bit architectures.

This patch introduces CONFIGURE_MAXIMUM_CAN_QUEUES to dynamically
inject the required CAN worker tasks into the master _CONFIGURE_TASKS
pool. Because the 404-byte usage falls below RTEMS_MINIMUM_STACK_SIZE,
provisioning them as standard system tasks automatically guarantees
sufficient stack space overhead.

Additionally, this patch removes the hardcoded +0x1000 stack padding
in rtems_task_create to prevent workspace exhaustion, and adds the
spcan01 test to verify the CONFIGURE_MAXIMUM_CAN_QUEUES macro behavior.

Closes #5193
This commit is contained in:
M Mithilesh
2026-07-02 17:36:27 -05:00
committed by Kinsey Moore
parent 0a0b69aeb0
commit 77eda6f760
5 changed files with 98 additions and 3 deletions
+1 -1
View File
@@ -465,7 +465,7 @@ int rtems_can_queue_kern_initialize( void )
sc = rtems_task_create(
rtems_build_name( 'C', 'A', 'N', 'D' ),
CAN_DEAD_FUNC_PRIORITY,
RTEMS_MINIMUM_STACK_SIZE + 0x1000,
RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES,
RTEMS_DEFAULT_ATTRIBUTES,
&dead_func_id
+9 -2
View File
@@ -59,8 +59,15 @@
#define CONFIGURE_MAXIMUM_TASKS 0
#endif
#define _CONFIGURE_TASKS \
( CONFIGURE_MAXIMUM_TASKS + _CONFIGURE_LIBBLOCK_TASKS )
#ifdef CONFIGURE_MAXIMUM_CAN_CHIPS
#define _CONFIGURE_CAN_TASKS ( CONFIGURE_MAXIMUM_CAN_CHIPS + 1 )
#else
#define _CONFIGURE_CAN_TASKS 0
#endif
#define _CONFIGURE_TASKS \
( CONFIGURE_MAXIMUM_TASKS + _CONFIGURE_LIBBLOCK_TASKS + \
_CONFIGURE_CAN_TASKS )
#ifndef CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE
#define CONFIGURE_MINIMUM_TASKS_WITH_USER_PROVIDED_STORAGE 0
+2
View File
@@ -168,6 +168,8 @@ links:
uid: spatomic01
- role: build-dependency
uid: spcache01
- role: build-dependency
uid: spcan01
- role: build-dependency
uid: spcbssched01
- role: build-dependency
+19
View File
@@ -0,0 +1,19 @@
SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause
build-type: test-program
cflags: []
copyrights:
- Copyright (C) 2026 Mithilesh Mattapalli
cppflags: []
cxxflags: []
enabled-by: true
features: c cprogram
includes: []
ldflags: []
links: []
source:
- testsuites/sptests/spcan01/init.c
stlib: []
target: testsuites/sptests/spcan01.exe
type: build
use-after: []
use-before: []
+67
View File
@@ -0,0 +1,67 @@
/* SPDX-License-Identifier: BSD-2-Clause */
/*
* Copyright (C) 2026 Mithilesh Mattapalli
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <rtems.h>
#include <tmacros.h>
#include <dev/can/can.h>
#include <dev/can/can-virtual.h>
const char rtems_test_name[] = "SPCAN 1";
static rtems_task Init( rtems_task_argument ignored )
{
struct rtems_can_chip *chip;
(void) ignored;
rtems_print_printer_fprintf_putc( &rtems_test_printer );
TEST_BEGIN();
chip = rtems_can_virtual_initialize();
rtems_test_assert( chip != NULL );
TEST_END();
rtems_test_exit( 0 );
}
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
#define CONFIGURE_MAXIMUM_TASKS 1
#define CONFIGURE_MAXIMUM_SEMAPHORES 10
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 10
#define CONFIGURE_MAXIMUM_CAN_CHIPS 1
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
#define CONFIGURE_INIT
#include <rtems/confdefs.h>