From nobody Tue Apr 7 14:36:46 2026 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9CF53290AE for ; Thu, 12 Mar 2026 19:21:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773343308; cv=none; b=D3Cacrpe47h5EXMKKhO3bgJw8NjZfTkFGolsHq8Zr2zgK36zktgmKFEzC4zZUBgNrt/iBAdAC0rN3DnaqurybNHk5z+BNInq/fUSRqKOftwyC26mptt3gxGzaq+chuuGyvrKXsuxKz7q2Of1PAUmTXuZ1qOi7AgdJgS3PIueQMc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773343308; c=relaxed/simple; bh=mYB5qUPbJskiTiV+/O6NfW8jJ90FmigMs0IxxKHtmZA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=h1Io4r2UIdimf9QDU6IIw354wIk71CE0JzOffKRmUhzwNl/DLKVpBNCE93J6rDsVewXALcKBpGs67+0t+Wr6SDEHwGWWx2oxit2nO5oHYWYuJCOVieTq9AWYIx7Af5CM8ig8UJoQsG4u4CtaE7BguMImXb1Tx52oMqN7Nj3C7iw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZvzJ4cCT; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZvzJ4cCT" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-8296dabef74so1353206b3a.1 for ; Thu, 12 Mar 2026 12:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773343306; x=1773948106; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2E7o9mf9DFu5JCjWUjXsYbAic15IwHrJMx4QeoSfAR4=; b=ZvzJ4cCTWeLVik0qfboUR/jOrRZqCp5SF1I7cR4K+vlXYSlmgqjKZOxIGXpkRdGgFK CC11d0TYs4rpsf1KIF5/TU61OFU+ZjNuTUY40zWGrAR7hxZd+taf9LPYpouLQtPpEh6m Hmqw2YhUY9I150U+FpkZnrguvdNKpqcwBH5olS88I7/N9XKRiM6ZMzvYmCNsPznM8im6 A7VMjJpjDp705+MOPazlOhasPBLFC4bxfXDE3Xhv7oA2txj+hDtQkQYNmdt/WbYPbnVl /V0KTlT8h07UIto1/E4uk04jLzag/rvW5KCGnPvtltBI++CHqHIwJL5g0+ROtaWe9u2H /i5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773343306; x=1773948106; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2E7o9mf9DFu5JCjWUjXsYbAic15IwHrJMx4QeoSfAR4=; b=QHyhSRWQLPMbMjaJaibT6FGPbWfNWUL55GzUl1CKWoSRIh0AWSBYDD5x3wTIr7OolO 1N8cWHuTqTaw3m004cz1vPQbZLuQJOZCefj2j9VgsBRyOdMYt+KxMaaY4aXjGoD0OmmY 31cOAU7tQ14s1tIXbtShrdyAFNc6AejGCbyWANx9WzlEYGBB+mYIdDorsXcUFvbUMVg2 VWje2QcAK/kXpRexNa5jiKTC775MBQ89fTNeRTwe+CPzbgYMyfddixaHekpOKkuGE441 swuoJhn2NFPDxtBD/AGJayZuLAnCtBnyfnlz+/ZJCez/4n95lz8x5uyhGKHYgWYIh0G8 vZ5Q== X-Forwarded-Encrypted: i=1; AJvYcCVdP7iPOUMVpKDvhv6P9Ouqy10Wkt39Vaxh/Oin1EVbfQSybUb2ErB01C938LMlV2up0+JMoNYh+nNnadE=@vger.kernel.org X-Gm-Message-State: AOJu0YzKzVunRVZy9VOZ5PDFxKJ0B3O6ADewC0Io7Oj898iNS3YtZQCF 7T7GVNVFSVxDuPePoJdPRI1ZiU/mYCC+TqAhqP4/7EdORKWX4nwND7Qh X-Gm-Gg: ATEYQzwu01BUrtBSaXiU9eccaUvojQKJ7iRs2NR0nc4NPZnR0hSAOBJPvfpgp8FKjVv BaPGJLdZX47CfCrwVMV5MmQl/qYwuUTQsJZUMdn+CE0wOJUo9PoF3v3WuLPGE9iNg/bOvOD8mzJ OWqjKBZ2es7qrSwsy7dFhaIx3zWjWiL1ahax07n179MBRooJNu1jQnST7NnbH/DFMZpt7r5Mkno ROlvQoAPmphlX/tzOfbZFkXheknKRduH6G51GIIAGRJO5E1+ysfuON+F1wlJkyssiZPPiuGa5TB Z8bP1n9ZuGtZuLQtVfAIQGOaPecjHAYpvPFPjDHd684tte/jL+5Mgjx1JjSsbY90Dua6rYTMjDh wbPkD2axeVZyCRBIKErGalDZS1GQaCqPhgy1eh02wSv1MF7AsZF6J4p6Wlijk0qFUvP7at3Pa0L 4D1XgRZneqbO20JTj6isQaYOuTWo71zGY1GC0FIwJBDGidrrGirgFumg== X-Received: by 2002:a05:6a00:190c:b0:81b:8872:ae10 with SMTP id d2e1a72fcca58-82a1958bfeamr561146b3a.0.1773343305938; Thu, 12 Mar 2026 12:21:45 -0700 (PDT) Received: from ryzen ([2601:644:8000:56f5::8bd]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82a0725e05esm4549179b3a.18.2026.03.12.12.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2026 12:21:45 -0700 (PDT) From: Rosen Penev To: dri-devel@lists.freedesktop.org Cc: Frank Binns , Matt Coster , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH] drm/imagination: simplify pvr_fw_trace_seq_data Date: Thu, 12 Mar 2026 12:21:28 -0700 Message-ID: <20260312192128.4133-1-rosenp@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A flexible array member allows one allocation instead of two. Which means one less kfree to worry about. Signed-off-by: Rosen Penev --- drivers/gpu/drm/imagination/pvr_fw_trace.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/imagination/pvr_fw_trace.c b/drivers/gpu/drm/i= magination/pvr_fw_trace.c index e154cb35f604..99d002b481a9 100644 --- a/drivers/gpu/drm/imagination/pvr_fw_trace.c +++ b/drivers/gpu/drm/imagination/pvr_fw_trace.c @@ -241,9 +241,6 @@ update_logtype(struct pvr_device *pvr_dev, u32 group_ma= sk) } =20 struct pvr_fw_trace_seq_data { - /** @buffer: Pointer to copy of trace data. */ - u32 *buffer; - /** @start_offset: Starting offset in trace data, as reported by FW. */ u32 start_offset; =20 @@ -252,6 +249,9 @@ struct pvr_fw_trace_seq_data { =20 /** @assert_buf: Trace assert buffer, as reported by FW. */ struct rogue_fwif_file_info_buf assert_buf; + + /** @buffer: Copy of trace data. */ + u32 buffer[]; }; =20 static u32 find_sfid(u32 id) @@ -455,17 +455,10 @@ static int fw_trace_open(struct inode *inode, struct = file *file) struct pvr_fw_trace_seq_data *trace_seq_data; int err; =20 - trace_seq_data =3D kzalloc_obj(*trace_seq_data); + trace_seq_data =3D kzalloc_flex(*trace_seq_data, buffer, ROGUE_FW_TRACE_B= UF_DEFAULT_SIZE_IN_DWORDS); if (!trace_seq_data) return -ENOMEM; =20 - trace_seq_data->buffer =3D kcalloc(ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWO= RDS, - sizeof(*trace_seq_data->buffer), GFP_KERNEL); - if (!trace_seq_data->buffer) { - err =3D -ENOMEM; - goto err_free_data; - } - /* * Take a local copy of the trace buffer, as firmware may still be * writing to it. This will exist as long as this file is open. @@ -478,15 +471,12 @@ static int fw_trace_open(struct inode *inode, struct = file *file) =20 err =3D seq_open(file, &pvr_fw_trace_seq_ops); if (err) - goto err_free_buffer; + goto err_free_data; =20 ((struct seq_file *)file->private_data)->private =3D trace_seq_data; =20 return 0; =20 -err_free_buffer: - kfree(trace_seq_data->buffer); - err_free_data: kfree(trace_seq_data); =20 @@ -499,7 +489,6 @@ static int fw_trace_release(struct inode *inode, struct= file *file) ((struct seq_file *)file->private_data)->private; =20 seq_release(inode, file); - kfree(trace_seq_data->buffer); kfree(trace_seq_data); =20 return 0; --=20 2.53.0