mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 05:44:11 +00:00
dma-mapping fixes for Linux 6.6
- move a dma-debug call that prints a message out from a lock that's causing problems with the lock order in serial drivers (Sergey Senozhatsky) - fix the CONFIG_DMA_NUMA_CMA Kconfig entry to have the right dependency on not default to y (Christoph Hellwig) - move an ifdef a bit to remove a __maybe_unused that seems to trip up some sensitivities (Christoph Hellwig) - revert a bogus check in the CMA allocator (Zhenhua Huang) -----BEGIN PGP SIGNATURE----- iQI/BAABCgApFiEEgdbnc3r/njty3Iq9D55TZVIEUYMFAmT8MJ8LHGhjaEBsc3Qu ZGUACgkQD55TZVIEUYOOyg/7BaZt4lih24cSFhXsU10wB49cKQuOngsT+4KFX7Eg 8LqdCK/L61M1VWm/1tcw6/XKK7oBDADIWnlutFTv1BHIaC0fjbFk0IpOQyWoXsYE vlCzm6Sh1rrryYK/dviLwC3+ccF33C5dzsZsKzeJ89v0cP//rENdOfXhwAIT2Wc7 FG/h0W7wWeQG4jHCz+DGhRp7X6r5urwW72KNap4BlBaDpZdAV9E5w1OeaplnENXt E7CK8rnHZz/AgH98LIMa929fgNhJ7Bec5mV9pItpBzYWAwL2iWk6k11FbAkxDiFQ MQ7gMnH5KRkCVpH/QILX1NU5ImsjdjyCUYn+2q8OJ5Y2C42K7V5ClspIgBCFk7XH AbCAGveoRUoQ3iCnQYZ0YPJOtyNSaUNB+q4NzwR/WFipiXGJBPflggI8gPzRiN8e 8SnKhduODklzLhOZZr7+nUEJpmwgR8aCkmhERZN/bw8iidBs/chiy9t1PfLmiOH9 R545BWEfsgpRikpEgb0HnuGD/zg26LcugLUilNbSZq0fzH4tkD5iCKKUitAITYLP ED0wDj9AdyQ98L6aSgAxc+9ip3eATFntM6hlg/16Ve4zdDTbFgucZpJhdSuVF8BI rq1VV3wztUm++zhkTFptK9eN2T+AQtpC+3XI6QyXpByADbX+m8GbQJm+r8V3hu5A X64= =AvYr -----END PGP SIGNATURE----- Merge tag 'dma-mapping-6.6-2023-09-09' of git://git.infradead.org/users/hch/dma-mapping Pull dma-mapping fixes from Christoph Hellwig: - move a dma-debug call that prints a message out from a lock that's causing problems with the lock order in serial drivers (Sergey Senozhatsky) - fix the CONFIG_DMA_NUMA_CMA Kconfig entry to have the right dependency and not default to y (Christoph Hellwig) - move an ifdef a bit to remove a __maybe_unused that seems to trip up some sensitivities (Christoph Hellwig) - revert a bogus check in the CMA allocator (Zhenhua Huang) * tag 'dma-mapping-6.6-2023-09-09' of git://git.infradead.org/users/hch/dma-mapping: Revert "dma-contiguous: check for memory region overlap" dma-pool: remove a __maybe_unused label in atomic_pool_expand dma-contiguous: fix the Kconfig entry for CONFIG_DMA_NUMA_CMA dma-debug: don't call __dma_entry_alloc_check_leak() under free_entries_lock
This commit is contained in:
commit
474197a4f7
4 changed files with 18 additions and 13 deletions
|
@ -160,7 +160,7 @@ if DMA_CMA
|
||||||
|
|
||||||
config DMA_NUMA_CMA
|
config DMA_NUMA_CMA
|
||||||
bool "Enable separate DMA Contiguous Memory Area for NUMA Node"
|
bool "Enable separate DMA Contiguous Memory Area for NUMA Node"
|
||||||
default NUMA
|
depends on NUMA
|
||||||
help
|
help
|
||||||
Enable this option to get numa CMA areas so that NUMA devices
|
Enable this option to get numa CMA areas so that NUMA devices
|
||||||
can get local memory by DMA coherent APIs.
|
can get local memory by DMA coherent APIs.
|
||||||
|
|
|
@ -473,11 +473,6 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memblock_is_region_reserved(rmem->base, rmem->size)) {
|
|
||||||
pr_info("Reserved memory: overlap with other memblock reserved region\n");
|
|
||||||
return -EBUSY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!of_get_flat_dt_prop(node, "reusable", NULL) ||
|
if (!of_get_flat_dt_prop(node, "reusable", NULL) ||
|
||||||
of_get_flat_dt_prop(node, "no-map", NULL))
|
of_get_flat_dt_prop(node, "no-map", NULL))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
|
@ -637,15 +637,19 @@ static struct dma_debug_entry *__dma_entry_alloc(void)
|
||||||
return entry;
|
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 */
|
/* Shout each time we tick over some multiple of the initial pool */
|
||||||
if (tmp < DMA_DEBUG_DYNAMIC_ENTRIES) {
|
if (tmp < DMA_DEBUG_DYNAMIC_ENTRIES) {
|
||||||
pr_info("dma_debug_entry pool grown to %u (%u00%%)\n",
|
pr_info("dma_debug_entry pool grown to %u (%u00%%)\n",
|
||||||
nr_total_entries,
|
nr_entries,
|
||||||
(nr_total_entries / nr_prealloc_entries));
|
(nr_entries / nr_prealloc_entries));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,8 +660,10 @@ static void __dma_entry_alloc_check_leak(void)
|
||||||
*/
|
*/
|
||||||
static struct dma_debug_entry *dma_entry_alloc(void)
|
static struct dma_debug_entry *dma_entry_alloc(void)
|
||||||
{
|
{
|
||||||
|
bool alloc_check_leak = false;
|
||||||
struct dma_debug_entry *entry;
|
struct dma_debug_entry *entry;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
u32 nr_entries;
|
||||||
|
|
||||||
spin_lock_irqsave(&free_entries_lock, flags);
|
spin_lock_irqsave(&free_entries_lock, flags);
|
||||||
if (num_free_entries == 0) {
|
if (num_free_entries == 0) {
|
||||||
|
@ -667,13 +673,17 @@ static struct dma_debug_entry *dma_entry_alloc(void)
|
||||||
pr_err("debugging out of memory - disabling\n");
|
pr_err("debugging out of memory - disabling\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
__dma_entry_alloc_check_leak();
|
alloc_check_leak = true;
|
||||||
|
nr_entries = nr_total_entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = __dma_entry_alloc();
|
entry = __dma_entry_alloc();
|
||||||
|
|
||||||
spin_unlock_irqrestore(&free_entries_lock, flags);
|
spin_unlock_irqrestore(&free_entries_lock, flags);
|
||||||
|
|
||||||
|
if (alloc_check_leak)
|
||||||
|
__dma_entry_alloc_check_leak(nr_entries);
|
||||||
|
|
||||||
#ifdef CONFIG_STACKTRACE
|
#ifdef CONFIG_STACKTRACE
|
||||||
entry->stack_len = stack_trace_save(entry->stack_entries,
|
entry->stack_len = stack_trace_save(entry->stack_entries,
|
||||||
ARRAY_SIZE(entry->stack_entries),
|
ARRAY_SIZE(entry->stack_entries),
|
||||||
|
|
|
@ -135,9 +135,9 @@ static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size,
|
||||||
remove_mapping:
|
remove_mapping:
|
||||||
#ifdef CONFIG_DMA_DIRECT_REMAP
|
#ifdef CONFIG_DMA_DIRECT_REMAP
|
||||||
dma_common_free_remap(addr, pool_size);
|
dma_common_free_remap(addr, pool_size);
|
||||||
#endif
|
free_page:
|
||||||
free_page: __maybe_unused
|
|
||||||
__free_pages(page, order);
|
__free_pages(page, order);
|
||||||
|
#endif
|
||||||
out:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue