Re: [PATCH 2/3] cpukit/jffs2: Implement JFFS2 spinlocks

2023-10-13 Thread Sebastian Huber

On 06.10.23 22:09, Kinsey Moore wrote:
This provides a non-noop implementation of spinlocks for JFFS2 in terms 
of RTEMS mutexes. POSIX spinlocks are not appropriate for the types of 
actions that occur during a held JFFS2 spinlock and can cause bad 
dispatch level conditions.


I think you are about to open a can of worms. So far, we had only one 
global lock for the complete JFFS2 instance. If you really want to start 
using the JFFS2 internal locking, then this should done thoroughly and 
not case by case from one issue to the next. All this delayed write 
stuff is currently not covered by tests.


--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH v2 3/9] bsps/leon3: Make GPTIMER fall back mandatory

2023-10-13 Thread Martin Åberg

Hello Sebastian,

My understanding is that with this patch, one GPTIMER subtimer is always 
allocated for the timecounter in uniprocessor configuration in the case 
of "use_gptimer".



Does this mean that the lower hardware requirement for all LEON3 systems 
is raised to require a GPTIMER with two available subtimers?
(Since the last hardware subtimer is typically dedicated to the watchdog 
function, three subtimers would in practice be needed.)



What are the implications when using RTEMS_MULTIPROCESSING together with 
"use_gptimer"?


In bsps/sparc/leon3/include/bsp/leon3.h, we have:
>  #if defined(RTEMS_MULTIPROCESSING)
>  #define LEON3_CLOCK_INDEX \
>( rtems_configuration_get_user_multiprocessing_table() ? 
LEON3_Cpu_Index : 0 )

>  #else
>  #define LEON3_CLOCK_INDEX 0
>  #endif

Can LEON3_COUNTER_GPTIMER_INDEX of CPU0 be equal to LEON3_CLOCK_INDEX of 
CPU1 here?



Best Regards,

--
Martin Åberg
Software Engineer
Frontgrade Gaisler
martin.ab...@gaisler.com

Frontgrade Gaisler AB, Kungsgatan 12, SE-411 19 GÖTEBORG, Sweden.
+46 (0) 31 775 8650, www.gaisler.com



On 2023-09-21 17:19, Sebastian Huber wrote:

Using the auto reload counter which generates the clock ticks for the
timecounter or CPU counter is quite difficult and only works in
uniprocessor configurations.

Update #4954.
---
  bsps/sparc/leon3/clock/ckinit.c  | 35 ++--
  bsps/sparc/leon3/include/bsp/leon3.h |  4 
  bsps/sparc/leon3/start/cpucounter.c  |  2 +-
  3 files changed, 3 insertions(+), 38 deletions(-)

diff --git a/bsps/sparc/leon3/clock/ckinit.c b/bsps/sparc/leon3/clock/ckinit.c
index eea4649fa3..d800f01e4a 100644
--- a/bsps/sparc/leon3/clock/ckinit.c
+++ b/bsps/sparc/leon3/clock/ckinit.c
@@ -69,19 +69,6 @@ static struct timecounter leon3_tc;
  
  static void leon3_tc_tick_default(void)

  {
-#if !defined(RTEMS_SMP)
-  SPARC_Counter *counter;
-  rtems_interrupt_level level;
-
-  counter = &_SPARC_Counter;
-  rtems_interrupt_local_disable(level);
-
-  grlib_store_32(&LEON3_IrqCtrl_Regs->iclear, counter->pending_mask);
-  counter->accumulated += counter->interval;
-
-  rtems_interrupt_local_enable(level);
-#endif
-
rtems_timecounter_tick();
  }
  
@@ -238,29 +225,11 @@ static void leon3_clock_use_gptimer(

gptimer_timer *timer
  )
  {
-#ifdef RTEMS_SMP
/*
-   * The GR712RC for example has no timestamp unit in the interrupt
-   * controller.  At least on SMP configurations we must use a second timer
-   * in free running mode for the timecounter.  The timer is initialized by
-   * leon3_counter_initialize().
+   * As a fall back, use a second timer in free-running mode for the
+   * timecounter.  The timer is initialized by leon3_counter_initialize().
 */
tc->tc_get_timecount = _SPARC_Get_timecount_down;
-#else
-  SPARC_Counter *counter;
-
-  counter = &_SPARC_Counter;
-  counter->read_isr_disabled = _SPARC_Counter_read_clock_isr_disabled;
-  counter->read = _SPARC_Counter_read_clock;
-  counter->counter_register = &timer->tcntval;
-  counter->pending_register = &LEON3_IrqCtrl_Regs->ipend;
-  counter->pending_mask = UINT32_C(1) << clkirq;
-  counter->accumulated = rtems_configuration_get_microseconds_per_tick();
-  counter->interval = rtems_configuration_get_microseconds_per_tick();
-
-  tc->tc_get_timecount = _SPARC_Get_timecount_clock;
-#endif
-
tc->tc_frequency = LEON3_GPTIMER_0_FREQUENCY_SET_BY_BOOT_LOADER,
  
rtems_timecounter_install(tc);

diff --git a/bsps/sparc/leon3/include/bsp/leon3.h 
b/bsps/sparc/leon3/include/bsp/leon3.h
index fdb43b5817..84790b590f 100644
--- a/bsps/sparc/leon3/include/bsp/leon3.h
+++ b/bsps/sparc/leon3/include/bsp/leon3.h
@@ -188,11 +188,7 @@ static inline uint32_t leon3_get_cpu_count( const irqamp 
*regs )
   * @brief This constant defines the index of the GPTIMER timer used by the
   *   CPU counter if the CPU counter uses the GPTIMER.
   */
-#if defined(RTEMS_SMP)
  #define LEON3_COUNTER_GPTIMER_INDEX ( LEON3_CLOCK_INDEX + 1 )
-#else
-#define LEON3_COUNTER_GPTIMER_INDEX LEON3_CLOCK_INDEX
-#endif
  
  /**

   * @brief This constant defines the frequency set by the boot loader of the
diff --git a/bsps/sparc/leon3/start/cpucounter.c 
b/bsps/sparc/leon3/start/cpucounter.c
index a6db7677a3..374e43c9b1 100644
--- a/bsps/sparc/leon3/start/cpucounter.c
+++ b/bsps/sparc/leon3/start/cpucounter.c
@@ -89,7 +89,7 @@ static void leon3_counter_use_gptimer(SPARC_Counter *counter, 
gptimer *gpt)
counter->read = _SPARC_Counter_read_down;
counter->counter_register = &timer->tcntval;
  
-  /* Make timer free running */

+  /* Make timer free-running */
grlib_store_32(&timer->trldval, 0x);
grlib_store_32(&timer->tctrl, GPTIMER_TCTRL_EN | GPTIMER_TCTRL_RS);
  

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH v2 3/9] bsps/leon3: Make GPTIMER fall back mandatory

2023-10-13 Thread Sebastian Huber

Hello Martin,

On 13.10.23 12:09, Martin Åberg wrote:

Hello Sebastian,

My understanding is that with this patch, one GPTIMER subtimer is always 
allocated for the timecounter in uniprocessor configuration in the case 
of "use_gptimer".


yes, exactly.




Does this mean that the lower hardware requirement for all LEON3 systems 
is raised to require a GPTIMER with two available subtimers?
(Since the last hardware subtimer is typically dedicated to the watchdog 
function, three subtimers would in practice be needed.)


Yes, but this requirement holds only for systems which do not provide an 
alternative free-running counter, such as the DSU time tag, IRQ(A)MP 
timestamp, %asr23, etc.





What are the implications when using RTEMS_MULTIPROCESSING together with 
"use_gptimer"?


In bsps/sparc/leon3/include/bsp/leon3.h, we have:
 >  #if defined(RTEMS_MULTIPROCESSING)
 >  #define LEON3_CLOCK_INDEX \
 >    ( rtems_configuration_get_user_multiprocessing_table() ? 
LEON3_Cpu_Index : 0 )

 >  #else
 >  #define LEON3_CLOCK_INDEX 0
 >  #endif

Can LEON3_COUNTER_GPTIMER_INDEX of CPU0 be equal to LEON3_CLOCK_INDEX of 
CPU1 here?


The individual RTEMS instances could share the GPTIMER configured in 
free-running mode.


The GR712RC and GR740 do not need the additional GPTIMER subtimer. Which 
products would be affected by this change? I hope that all future 
Gaisler products provide a free-running counter device with a capture 
feature for PPS.


--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel