From patchwork Mon Oct 14 16:36:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13835318 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8C6C1D18130 for ; Mon, 14 Oct 2024 16:37:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DF69310E482; Mon, 14 Oct 2024 16:37:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="bCsZwRNA"; dkim-atps=neutral Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5D54510E487 for ; Mon, 14 Oct 2024 16:37:34 +0000 (UTC) Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-71e6f1a5a19so470793b3a.3 for ; Mon, 14 Oct 2024 09:37:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728923854; x=1729528654; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Eq6RmtQgXylpaIuQSD/eFivfyV/YbUHAedXEkzzSSXc=; b=bCsZwRNARJo7zMvq3tqEgm4mdV+HuGFOlDnP0h6AO8R7daG+jKZWoEqEevHWE1oy0i FmXkOAEiLPjRocHMEXQbbPgJlFj0HTsAa6UZXhZUYww1RWQ3lUOmkIXZHw8CIuU2MrT2 x7YkGQa6fvXSYrBbbC109ul6bGSQXfqT2omAY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728923854; x=1729528654; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Eq6RmtQgXylpaIuQSD/eFivfyV/YbUHAedXEkzzSSXc=; b=E/0aIkO1NCFcjUewMp6AoV6m1HAG9lGXHvJlFpTqw0RCsQ2yHYGg43LWVLlUCN2BVJ fWmDwFyYLEVDU1YFIdiG0cQlafiupm8SPoTamMXca7Emgapip4rdItlB0WyE217VG45q cBBwlPO+tXxKUuDzTlUYsCnKzVS0UgrY6Q/tUOqxHcRe+6SrKbX0+qPqnzJ+R0GwGUdS sFnN7r3luexDsYMycZkctlbi9E8V0vSQRQ59A/rezkMtNVnhJSB6TUEKLlZi9+v7RLJ5 3rLTAc1ULB7tT3apUBDWYk9Hd0ykwHu6rBLEqrphyKGytJef6EAi9I3nF5xycABqJQnR TlpA== X-Forwarded-Encrypted: i=1; AJvYcCU16L1y3ZvEvYyEOzl1+yBBDP8DHj34Y5q4oNLZmU/P4xB8ybjAjo+QNtE4zl3RjIWgG54APqK4fN8=@lists.freedesktop.org X-Gm-Message-State: AOJu0YzhgrbHwOixIdIW7aNNM4J9nbg7UcZug2kwUZVlOwjmN6uERPfh WTx2h2kUZ+AeSa2bR5mHA963lMkeJmQtYnOeEDTL7JUHV9s12nzEVsStdtPMbQ== X-Google-Smtp-Source: AGHT+IFrI6AyFlAD+rPt6sq8RJjzjcPvxnHIHU5bh4fmZllt0MuEFWzqp3sZJTWGMBx/myacl4Lxew== X-Received: by 2002:a05:6a00:9282:b0:717:9154:b5d6 with SMTP id d2e1a72fcca58-71e37f4ed89mr19746704b3a.22.1728923853741; Mon, 14 Oct 2024 09:37:33 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:1e71:8a09:a3b:1e00]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e51dc0617sm4383693b3a.165.2024.10.14.09.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 09:37:32 -0700 (PDT) From: Douglas Anderson To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Stephen Boyd , Douglas Anderson , David Airlie , Marijn Suijten , Sean Paul , Simona Vetter , dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] drm/msm: Avoid NULL dereference in msm_disp_state_print_regs() Date: Mon, 14 Oct 2024 09:36:08 -0700 Message-ID: <20241014093605.1.Ia1217cecec9ef09eb3c6d125360cc6c8574b0e73@changeid> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" If the allocation in msm_disp_state_dump_regs() failed then `block->state` can be NULL. The msm_disp_state_print_regs() function _does_ have code to try to handle it with: if (*reg) dump_addr = *reg; ...but since "dump_addr" is initialized to NULL the above is actually a noop. The code then goes on to dereference `dump_addr`. Make the function print "Registers not stored" when it sees a NULL to solve this. Since we're touching the code, fix msm_disp_state_print_regs() not to pointlessly take a double-pointer and properly mark the pointer as `const`. Fixes: 98659487b845 ("drm/msm: add support to take dpu snapshot") Signed-off-by: Douglas Anderson Reviewed-by: Abhinav Kumar --- drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c b/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c index add72bbc28b1..bb149281d31f 100644 --- a/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +++ b/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c @@ -48,20 +48,21 @@ static void msm_disp_state_dump_regs(u32 **reg, u32 aligned_len, void __iomem *b } } -static void msm_disp_state_print_regs(u32 **reg, u32 len, void __iomem *base_addr, - struct drm_printer *p) +static void msm_disp_state_print_regs(const u32 *dump_addr, u32 len, + void __iomem *base_addr, struct drm_printer *p) { int i; - u32 *dump_addr = NULL; void __iomem *addr; u32 num_rows; + if (!dump_addr) { + drm_printf(p, "Registers not stored\n"); + return; + } + addr = base_addr; num_rows = len / REG_DUMP_ALIGN; - if (*reg) - dump_addr = *reg; - for (i = 0; i < num_rows; i++) { drm_printf(p, "0x%lx : %08x %08x %08x %08x\n", (unsigned long)(addr - base_addr), @@ -89,7 +90,7 @@ void msm_disp_state_print(struct msm_disp_state *state, struct drm_printer *p) list_for_each_entry_safe(block, tmp, &state->blocks, node) { drm_printf(p, "====================%s================\n", block->name); - msm_disp_state_print_regs(&block->state, block->size, block->base_addr, p); + msm_disp_state_print_regs(block->state, block->size, block->base_addr, p); } drm_printf(p, "===================dpu drm state================\n"); From patchwork Mon Oct 14 16:36:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13835319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2ECE0D1812F for ; Mon, 14 Oct 2024 16:37:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E8A4F10E48D; Mon, 14 Oct 2024 16:37:37 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="D/8pQxyo"; dkim-atps=neutral Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by gabe.freedesktop.org (Postfix) with ESMTPS id 712A610E48C for ; Mon, 14 Oct 2024 16:37:36 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-656d8b346d2so2800682a12.2 for ; Mon, 14 Oct 2024 09:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728923856; x=1729528656; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=y0QDCUs/8D4jixu/KfGYmNxOa4c0mSZ3kXKt5t3/Xv8=; b=D/8pQxyonrcE1GsY+LFLmLTwfgaXaykjvXiBJ3Ck2ts15X24XRIh6qqQDJlh4pPMrO uUlmdFKO9ug1kI5tElr6MbADNwiu+Q1SiHqECOJu72JaBx6WwzNCuULjDK+7ZT1IAbAy MswMFb2ppTb/ix6EFyILbI0oBkcQjawQw23as= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728923856; x=1729528656; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y0QDCUs/8D4jixu/KfGYmNxOa4c0mSZ3kXKt5t3/Xv8=; b=gyxdQNgc0cP4PYhKVhxVX2inatRJmfWq0hzGeD+cIxL7cLZNBw0nmdf6BZR8Jow7m+ ACT5I/bTAfSkId5lX4PKEBuXoLjGMNQXGlDmu6/O+rysKwDxTo8G8QOx+flp1cYWXLzb rhDLMuZv0izp74uhHiuBdGRltsUv2lMMOVAuRV5cUq0wbvo0kIYn/TXCCxF9zzkJafQp sNtuGghUcuagkKn/rsRRW7F7JTR24E240O3BPHXADsCmN1klFobIz82HNgm4UfkcdTjm aMMzONmDCYBWQe6ohHoEwGztgRu8WUnC6bNtIS8wu27fJ+gk2kXLDw0WXopaocbSspFK Ae6Q== X-Forwarded-Encrypted: i=1; AJvYcCXYbV1T6vg1KCazBH1EedkHRWvuXW7NAyfR8fnUAzAgYpOYLstuFviwsvU5s1EkwM8Tjd9uc6AMA5A=@lists.freedesktop.org X-Gm-Message-State: AOJu0YxrcpPy+jyyIt2Wrpx8Fp62peqGekGAEfwu9ankPzAgz3lQIoyu ubd7DGsd4me8wWbqVrwcR4U3aUT1D92KRoqAYMJejS7kIY1wxUgAKYxw/AqOowTCfE6pNuFafcA = X-Google-Smtp-Source: AGHT+IGux4tneH6GmBs7wM4quuJ0YGWj3+34YGtAX6dD/SdcV19l8y70Ofmfq5jY72pPsYNjcr0LjA== X-Received: by 2002:a05:6a21:168d:b0:1d8:bbc9:37c7 with SMTP id adf61e73a8af0-1d8c969074dmr13073659637.36.1728923855948; Mon, 14 Oct 2024 09:37:35 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:1e71:8a09:a3b:1e00]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e51dc0617sm4383693b3a.165.2024.10.14.09.37.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 09:37:35 -0700 (PDT) From: Douglas Anderson To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Stephen Boyd , Douglas Anderson , David Airlie , Marijn Suijten , Sean Paul , Simona Vetter , dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] drm/msm: Allocate memory for disp snapshot with kvzalloc() Date: Mon, 14 Oct 2024 09:36:09 -0700 Message-ID: <20241014093605.2.I72441365ffe91f3dceb17db0a8ec976af8139590@changeid> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241014093605.1.Ia1217cecec9ef09eb3c6d125360cc6c8574b0e73@changeid> References: <20241014093605.1.Ia1217cecec9ef09eb3c6d125360cc6c8574b0e73@changeid> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" With the "drm/msm: add a display mmu fault handler" series [1] we saw issues in the field where memory allocation was failing when allocating space for registers in msm_disp_state_dump_regs(). Specifically we were seeing an order 5 allocation fail. It's not surprising that order 5 allocations will sometimes fail after the system has been up and running for a while. There's no need here for contiguous memory. Change the allocation to kvzalloc() which should make it much less likely to fail. [1] https://lore.kernel.org/r/20240628214848.4075651-1-quic_abhinavk@quicinc.com/ Fixes: 98659487b845 ("drm/msm: add support to take dpu snapshot") Signed-off-by: Douglas Anderson Reviewed-by: Abhinav Kumar --- drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c b/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c index bb149281d31f..4d55e3cf570f 100644 --- a/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +++ b/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c @@ -26,7 +26,7 @@ static void msm_disp_state_dump_regs(u32 **reg, u32 aligned_len, void __iomem *b end_addr = base_addr + aligned_len; if (!(*reg)) - *reg = kzalloc(len_padded, GFP_KERNEL); + *reg = kvzalloc(len_padded, GFP_KERNEL); if (*reg) dump_addr = *reg; @@ -162,7 +162,7 @@ void msm_disp_state_free(void *data) list_for_each_entry_safe(block, tmp, &disp_state->blocks, node) { list_del(&block->node); - kfree(block->state); + kvfree(block->state); kfree(block); } From patchwork Mon Oct 14 16:36:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13835320 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F0EF6D18130 for ; Mon, 14 Oct 2024 16:37:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C50010E48F; Mon, 14 Oct 2024 16:37:40 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DrGK96AA"; dkim-atps=neutral Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9230410E48C for ; Mon, 14 Oct 2024 16:37:38 +0000 (UTC) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-71e70c32cd7so395005b3a.1 for ; Mon, 14 Oct 2024 09:37:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728923858; x=1729528658; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sVGl2ftbuqqnUqeIL1a1bElRQ/ry6hMTlQBnPSxP8Dk=; b=DrGK96AAtYnT7Ov0mWOFQVhsocHIYccTx0QgPZVBOqgwNsY4gi2A2zRB4r6nExildk covYrT5sYYkPHfmRBUoZa1ZKB+CCNlCYyDVdF9ToJ1D+V8esi+iriZpNn/A65xkYT748 wilGFOLEh1kDs8cFY4Dh4NH7/Pijz1GLmqSfg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728923858; x=1729528658; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sVGl2ftbuqqnUqeIL1a1bElRQ/ry6hMTlQBnPSxP8Dk=; b=qyDbh3d6hCVj/3bFD3zvMc43b9ON8IPk8nLLHmrlDXnRgV58x/f2gYrL9ay3X5MnGQ HnGs/D6BPx8k42mHwEYb7WH5TeI1zyfiXWWih0J6mLZ8p0DUUFAXYeuJCul23QE5k1nR DUg5DmSZpcRW5aVAu4tg+WKWARFhra7SrwrhD4qSnKQ8a6hQPl9ZEyYJiCSJzU5WwHIy YeexoOnStA6joyIgYnKjXlmY2Uj7NoyoPN3xRx6pAQ5Yp3CX0iTSO4lAAcZiPPGbCSrs +c0NhVr89V0njVi9kG8pHiXM4bNtvp2LAvEoSAHmEwRxWE4hQUv+vH8ZRS3RWXpsKBXB S68w== X-Forwarded-Encrypted: i=1; AJvYcCViTJp1G0DqPzMb1eVVFI724lRmtrL0H9LMOdIJWsV4aAdNrKxtGqXJ08aPsJfeC3utuyWR8cD+rHg=@lists.freedesktop.org X-Gm-Message-State: AOJu0YyThNCUAQG8cPdAUoDIjFppgGd8sb7UEEBNI2AqbIIBIwqpdeCC ZVzIl2F+NRmNDdDzvZpCTI3ts+dAfXZdbEGLc7Qjq856ulBZoYAK+MWnVBda6g== X-Google-Smtp-Source: AGHT+IEguS+DYgfr50X3amlVgerOKKT45qvqYFP4etgOkkRvUpQ1dDg9fKu0+t5LQwDSWp3K3ICKxw== X-Received: by 2002:a05:6a00:4652:b0:71e:4c86:659a with SMTP id d2e1a72fcca58-71e4c866d72mr13703071b3a.9.1728923858137; Mon, 14 Oct 2024 09:37:38 -0700 (PDT) Received: from dianders.sjc.corp.google.com ([2620:15c:9d:2:1e71:8a09:a3b:1e00]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71e51dc0617sm4383693b3a.165.2024.10.14.09.37.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 09:37:37 -0700 (PDT) From: Douglas Anderson To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov Cc: Stephen Boyd , Douglas Anderson , David Airlie , Marijn Suijten , Sean Paul , Simona Vetter , dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] drm/msm: Simplify NULL checking in msm_disp_state_dump_regs() Date: Mon, 14 Oct 2024 09:36:10 -0700 Message-ID: <20241014093605.3.I66049c2c17bd82767661f0ecd741b20453da02b2@changeid> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241014093605.1.Ia1217cecec9ef09eb3c6d125360cc6c8574b0e73@changeid> References: <20241014093605.1.Ia1217cecec9ef09eb3c6d125360cc6c8574b0e73@changeid> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The msm_disp_state_dump_regs(): - Doesn't allocate if the caller already allocated. ...but there's one caller and it doesn't allocate so we don't need this check. - Checks for allocation failure over and over even though it could just do it once right after the allocation. Clean this up. Signed-off-by: Douglas Anderson Reviewed-by: Abhinav Kumar --- .../gpu/drm/msm/disp/msm_disp_snapshot_util.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c b/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c index 4d55e3cf570f..07a2c1e87219 100644 --- a/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +++ b/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c @@ -25,24 +25,21 @@ static void msm_disp_state_dump_regs(u32 **reg, u32 aligned_len, void __iomem *b addr = base_addr; end_addr = base_addr + aligned_len; - if (!(*reg)) - *reg = kvzalloc(len_padded, GFP_KERNEL); - - if (*reg) - dump_addr = *reg; + *reg = kvzalloc(len_padded, GFP_KERNEL); + if (!*reg) + return; + dump_addr = *reg; for (i = 0; i < num_rows; i++) { x0 = (addr < end_addr) ? readl_relaxed(addr + 0x0) : 0; x4 = (addr + 0x4 < end_addr) ? readl_relaxed(addr + 0x4) : 0; x8 = (addr + 0x8 < end_addr) ? readl_relaxed(addr + 0x8) : 0; xc = (addr + 0xc < end_addr) ? readl_relaxed(addr + 0xc) : 0; - if (dump_addr) { - dump_addr[i * 4] = x0; - dump_addr[i * 4 + 1] = x4; - dump_addr[i * 4 + 2] = x8; - dump_addr[i * 4 + 3] = xc; - } + dump_addr[i * 4] = x0; + dump_addr[i * 4 + 1] = x4; + dump_addr[i * 4 + 2] = x8; + dump_addr[i * 4 + 3] = xc; addr += REG_DUMP_ALIGN; }