Unverified Commit 1a199472 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!6120 dma-debug: don't call __dma_entry_alloc_check_leak() under free_entries_lock

parents 011ea9d2 c1e429ec
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -606,15 +606,19 @@ static struct dma_debug_entry *__dma_entry_alloc(void)
	return entry;
}

static void __dma_entry_alloc_check_leak(void)
/*
 * This should be called outside of free_entries_lock scope to avoid potential
 * deadlocks with serial consoles that use DMA.
 */
static void __dma_entry_alloc_check_leak(u32 nr_entries)
{
	u32 tmp = nr_total_entries % nr_prealloc_entries;
	u32 tmp = nr_entries % nr_prealloc_entries;

	/* Shout each time we tick over some multiple of the initial pool */
	if (tmp < DMA_DEBUG_DYNAMIC_ENTRIES) {
		pr_info("dma_debug_entry pool grown to %u (%u00%%)\n",
			nr_total_entries,
			(nr_total_entries / nr_prealloc_entries));
			nr_entries,
			(nr_entries / nr_prealloc_entries));
	}
}

@@ -625,8 +629,10 @@ static void __dma_entry_alloc_check_leak(void)
 */
static struct dma_debug_entry *dma_entry_alloc(void)
{
	bool alloc_check_leak = false;
	struct dma_debug_entry *entry;
	unsigned long flags;
	u32 nr_entries;

	spin_lock_irqsave(&free_entries_lock, flags);
	if (num_free_entries == 0) {
@@ -636,13 +642,17 @@ static struct dma_debug_entry *dma_entry_alloc(void)
			pr_err("debugging out of memory - disabling\n");
			return NULL;
		}
		__dma_entry_alloc_check_leak();
		alloc_check_leak = true;
		nr_entries = nr_total_entries;
	}

	entry = __dma_entry_alloc();

	spin_unlock_irqrestore(&free_entries_lock, flags);

	if (alloc_check_leak)
		__dma_entry_alloc_check_leak(nr_entries);

#ifdef CONFIG_STACKTRACE
	entry->stack_len = stack_trace_save(entry->stack_entries,
					    ARRAY_SIZE(entry->stack_entries),