From a6728ac176baa10714127ff601b091f4c1af9cbd Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Fri, 5 Nov 2010 18:00:09 -0500 Subject: [PATCH] dahdi-wip: Fix 'dynamic_loc' span operation with DAHDI internal timing. DAHDI_CONFIG_CORE_TIMER allows DAHDI to always provide timing regardless of the state of any span. Unfortunately, dynamic spans "tick" in the context of master span processing. This can result in recursive calls to prdynamic spans "tick" in the context of master span processing. This can result in recursive calls to process_masterpan if local spans are ever set as the master span. This patch prevents recursive calls to process_masterspan, but I think a better solution would be to mark spans as never providing timing. (issue #13205) Reported by: biohumanoid Signed-off-by: Shaun Ruffell --- drivers/dahdi/dahdi-base.c | 24 ++++++++++++++++++++---- drivers/dahdi/dahdi_dynamic.c | 2 +- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index 1e61272..1d7ad03 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -227,6 +227,7 @@ static struct core_timer { atomic_t count; atomic_t shutdown; atomic_t last_count; + bool calling_process_masterspan; } core_timer; #endif /* CONFIG_DAHDI_CORE_TIMER */ @@ -8314,7 +8315,7 @@ int dahdi_transmit(struct dahdi_span *span) return 0; } -static void process_masterspan(void) +static void __process_masterspan(void) { unsigned long flags; int x, y; @@ -8328,7 +8329,8 @@ static void process_masterspan(void) * to the core timer, we know how many times we need to call * process_masterspan in order to catch up since this function needs * to be called (1000 / (DAHDI_CHUNKSIZE / 8)) times per second. */ - atomic_inc(&core_timer.count); + if (!core_timer.calling_process_masterspan) + atomic_inc(&core_timer.count); #endif /* Hold the chan_lock for the duration of major activities which touch all sorts of channels */ @@ -8401,6 +8403,16 @@ static void process_masterspan(void) spin_unlock_irqrestore(&chan_lock, flags); } +#ifdef CONFIG_DAHDI_CORE_TIMER +static inline void process_masterspan(void) +{ + if (!core_timer.calling_process_masterspan) + __process_masterspan(); +} +#else +#define process_masterspan() __process_masterspan() +#endif + #ifndef CONFIG_DAHDI_CORE_TIMER static void coretimer_init(void) @@ -8482,8 +8494,12 @@ static void coretimer_func(unsigned long param) return; } - while (ms_since_start > msecs_processed(&core_timer)) - process_masterspan(); + core_timer.calling_process_masterspan = true; + while (ms_since_start > msecs_processed(&core_timer)) { + __process_masterspan(); + atomic_inc(&core_timer.count); + } + core_timer.calling_process_masterspan = false; if (ms_since_start > MAX_INTERVAL) { atomic_set(&core_timer.count, 0); diff --git a/drivers/dahdi/dahdi_dynamic.c b/drivers/dahdi/dahdi_dynamic.c index 1a1d84b..840e3d3 100644 --- a/drivers/dahdi/dahdi_dynamic.c +++ b/drivers/dahdi/dahdi_dynamic.c @@ -43,7 +43,7 @@ * tasklets. */ -#define ENABLE_TASKLETS +#undef ENABLE_TASKLETS /* * Dynamic spans implemented using TDM over X with standard message -- 1.7.2.3