Hi Jared,
On Thu, Apr 24, 2025 at 09:11:24AM -0700, Jared Kangas wrote:
struct cma_heap { struct dma_heap *heap; @@ -394,15 +395,26 @@ static int __init __add_cma_heap(struct cma *cma, const char *name) static int __init add_default_cma_heap(void) { struct cma *default_cma = dev_get_cma_area(NULL);
- const char *legacy_cma_name; int ret;
if (!default_cma) return 0;
- ret = __add_cma_heap(default_cma, cma_get_name(default_cma));
- ret = __add_cma_heap(default_cma, DEFAULT_CMA_NAME); if (ret) return ret;
- legacy_cma_name = cma_get_name(default_cma);
- if (IS_ENABLED(CONFIG_DMABUF_HEAPS_CMA_LEGACY) &&
strcmp(legacy_cma_name, DEFAULT_CMA_NAME)) {
ret = __add_cma_heap(default_cma, legacy_cma_name);
if (ret)
pr_warn("cma_heap: failed to add legacy heap: %pe\n",
ERR_PTR(-ret));
- }
It would also simplify this part, since you would always create the legacy heap.
By "always", do you mean removing the strcmp? I added this to guard against cases where the devicetree node's name clashed with the default name, given that the DT name isn't necessarily restricted to one of the current names in use ("linux,cma" or "default-pool"). It seems like the strcmp would be relevant regardless of the naming choice, but if this is overly cautious, I can remove it in v3.
That's not overly cautious, that's something I overlooked :)
You're totally right that we should check for that. We should probably add a more specific error message in that case though
Maxime
linaro-mm-sig@lists.linaro.org