e fallback when `a5xx_zap_shader_init()` returns `-ENODEV`. - Previously, if `of_address_to_resource()` failed, the code returned an error without setting `zap_available = false`. That meant callers saw a generic error (not `-ENODEV`) and aborted bring-up instead of taking the designed fallback. This is precisely the oversight the commit fixes. - Impact and risk assessment - Scope is small and contained to one function in a single driver file. No architectural changes. - Behavior change is specifically in error handling: failures to resolve “memory-region” now reliably signal “zap not available,” aligning with the existing, intentional `-ENODEV` fallback path in the Adreno bring-up sequence. - Using `of_reserved_mem_region_to_resource()` ensures the driver only uses regions actually initialized by the reserved-memory core (drivers/of/of_reserved_mem.c) and returns `-ENODEV` if the memory- region is missing or unavailable. This is safer than reading “reg” directly from the node and avoids mapping memory that wasn’t properly reserved. - Note: the function no longer calls `of_node_put(np)` after `of_get_child_by_name()`. There was already at least one leak path for `np` (the early `!of_device_is_available(np)` return). This commit removes the `of_node_put(np)` that existed on the success path. The leak is a single DT node ref during probe/init and practically negligible. It does not outweigh the bugfix in error handling. If desired, a follow-up to put `np` after use is trivial and independent of this fix. - Stable backport considerations - This is a clear bugfix with a targeted change in error handling and a move to the correct reserved-memory API. - If a given stable series already has `of_reserved_mem_region_to_resource()`, this applies cleanly and is low risk. - If not, the minimal backport can keep the existing `of_address_to_resource()` path but still add the key fix (set `zap_available = false` when it fails), preserving the functional improvement with minimal churn. - Conclusion - The change fixes a real user-visible issue (unnecessary bring-up failure instead of the intended fallback), is small and localized, and reduces misuse of DT reserved-memory. It satisfies stable criteria as a low-risk bugfix suitable for backport. drivers/gpu/drm/msm/adreno/adreno_gpu.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index f1230465bf0d0..8c6336b007dc0 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -33,7 +33,7 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname, struct device *dev = &gpu->pdev->dev; const struct firmware *fw; const char *signed_fwname = NULL; - struct device_node *np, *mem_np; + struct device_node *np; struct resource r; phys_addr_t mem_phys; ssize_t mem_size; @@ -51,18 +51,11 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname, return -ENODEV; } - mem_np = of_parse_phandle(np, "memory-region", 0); - of_node_put(np); - if (!mem_np) { + ret = of_reserved_mem_region_to_resource(np, 0, &r); + if (ret) { zap_available = false; - return -EINVAL; - } - - ret = of_address_to_resource(mem_np, 0, &r); - of_node_put(mem_np); - if (ret) return ret; - + } mem_phys = r.start; /* -- 2.51.0[PATCH AUTOSEL 6.17] drm/msm: Use of_reserved_mem_region_to_resource() for "memory-region"Sasha Levin undefinedpatches@lists.linux.dev, stable@vger.kernel.org undefined undefined undefined undefined undefined undefined undefined undefined