From patchwork Wed Aug 28 13:13:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Coster X-Patchwork-Id: 13781273 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 C4CF3C54FB3 for ; Wed, 28 Aug 2024 13:17:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F38510E516; Wed, 28 Aug 2024 13:17:34 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=imgtec.com header.i=@imgtec.com header.b="KEPnRghg"; dkim=pass (1024-bit key; unprotected) header.d=IMGTecCRM.onmicrosoft.com header.i=@IMGTecCRM.onmicrosoft.com header.b="U5s1ONyO"; dkim-atps=neutral X-Greylist: delayed 476 seconds by postgrey-1.36 at gabe; Wed, 28 Aug 2024 13:17:32 UTC Received: from mx08-00376f01.pphosted.com (mx08-00376f01.pphosted.com [91.207.212.86]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7A78010E514 for ; Wed, 28 Aug 2024 13:17:32 +0000 (UTC) Received: from pps.filterd (m0168888.ppops.net [127.0.0.1]) by mx08-00376f01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 47S65SJa027701; Wed, 28 Aug 2024 14:13:49 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imgtec.com; h=cc :content-type:date:from:message-id:mime-version:subject:to; s= dk201812; bh=zc7wO1crYB+L2870y6hBfWcTpWloF9+TBp6CiSne3ac=; b=KEP nRghgDfJAP51neSMXhLTi8VmSnP/oVMYxPenk0DgdbKQRzcVl8aeJEQdUU2xqeGv ueSOBy6DAzL9plEX0/hW1Z7RqPN+ZG5fskinl+8E1Y5jjqqPArk7EE4CeUTWfPVk 0L6NHA1lyzyEhkqlnT4sVXNdgVl0q+y8VY1elbTT6tIgF8PtBGxWyY+OYb5KFuXF jygxlJf689XBmytewDlBDZ/XeoTW95JyyjA1P/tBxQvVa3ko8jpCVb9XiUxgEB7z CjmZXFpFxLCvL9OlY1jxFxP9BPV9ER9P8qPXhiX4EJ/d7UE23ue1udaZas0vvSSQ 9J8fSYoU0/MxPmJ/3VA== Received: from hhmail04.hh.imgtec.org ([217.156.249.195]) by mx08-00376f01.pphosted.com (PPS) with ESMTPS id 4175ss31ta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 28 Aug 2024 14:13:48 +0100 (BST) Received: from HHMAIL05.hh.imgtec.org (10.100.10.120) by HHMAIL04.hh.imgtec.org (10.100.10.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Wed, 28 Aug 2024 14:13:47 +0100 Received: from CWXP265CU008.outbound.protection.outlook.com (40.93.68.3) by email.imgtec.com (10.100.10.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37 via Frontend Transport; Wed, 28 Aug 2024 14:13:47 +0100 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Vc/+mfrLG6Q6iNNySAdzp1/gbRWCmcaoL/pkgEzLkOeh/4P4vSQllBFMKMp0KfIDp0pi2Od582navLZHYxqAYnsDRmZTAP1fCtRLx8nufzD+mNeRWZ7RXUfhq/JPFTNE/WsPvyTstddZMf92lMUa+0k4x/H2ehqPdg2TOhYW8uJWrWZEgjIQEY0zafFykAq8NzwpaC0YyoIYBDFQQXuHCzAhRL8is/E6z4+Yxd7EZRmxzqrRYpkUiSQygc3U5ECMXX5eq2+X/z9NK9RfmeI4NQZGZ6Am7r7ehoWDexMX8tULzJObXVa2znOdQsGuIIvaPds9/x/8OLPBuQg7a7/bpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zc7wO1crYB+L2870y6hBfWcTpWloF9+TBp6CiSne3ac=; b=BZAagSEELM6gmxDmZGTuxwiA96T+oaUr0tuTKaOlIy3SpzxPkuniQ7NshTSdfS4YAv2KjKNr33OJhNreWE9b8eKoh46e5tArJYR9BnfxZlzZA3klVP4OQHQS5tPQlLWzs6EIR7PbUr5aInI0TMo8Sv0fK3AzXffqENZUMnDtSxcgrR9I33R5ZViRxNINKt2DWfCKV+OnFu2Eew6h2XQPEnE3gQVySo6kL5S5x32oHZYxWgPbE/wDqc5kCXKykJdtviyIfcx0gRgzRkay+29B4uYweEWJ5JU4n6DtSQCkVCQ0QngKS/tLEXMh2nNlCTSGnVlfQYaIAOGT6+e7xF6hCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=imgtec.com; dmarc=pass action=none header.from=imgtec.com; dkim=pass header.d=imgtec.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=IMGTecCRM.onmicrosoft.com; s=selector2-IMGTecCRM-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zc7wO1crYB+L2870y6hBfWcTpWloF9+TBp6CiSne3ac=; b=U5s1ONyOsb0ucqIc/QtrFNyhqx93FM2E0UdsrtGt9RvlinaRjO4bHsyJMifCMfmhC6FWRrNPmbE8xEsPLQFbNDQ5clG1wnAn6gXOQrtT3hc+QBHJH7e60fdwbWdL7H41GEWhqLHkp2CzWUuJAVpGNBWRgHlHq0z9b54ysze/uWM= Received: from CWXP265MB3397.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:e7::8) by LO4P265MB6201.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:27e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.26; Wed, 28 Aug 2024 13:13:45 +0000 Received: from CWXP265MB3397.GBRP265.PROD.OUTLOOK.COM ([fe80::8e9d:6b2f:9881:1e15]) by CWXP265MB3397.GBRP265.PROD.OUTLOOK.COM ([fe80::8e9d:6b2f:9881:1e15%5]) with mapi id 15.20.7897.027; Wed, 28 Aug 2024 13:13:45 +0000 From: Matt Coster To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" CC: Frank Binns Subject: [PATCH] drm/imagination: Free pvr_vm_gpuva after unlink Thread-Topic: [PATCH] drm/imagination: Free pvr_vm_gpuva after unlink Thread-Index: AQHa+UwcGN9gt+LUvkOIDStkvzixGQ== Date: Wed, 28 Aug 2024 13:13:45 +0000 Message-ID: <9f26a943-1573-43a6-a919-d6425d9df34e@imgtec.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CWXP265MB3397:EE_|LO4P265MB6201:EE_ x-ms-office365-filtering-correlation-id: 1e58505b-89f4-4daa-ba67-08dcc7633eea x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|1800799024|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?OJxsIcaCnZfpDTSR/HA2QeZtG04bbYo?= =?utf-8?q?zVoHg7k5up9Lt+kW5lo6M6tOznl0vacVLKBpxfnChAndC4xkBWExSpw0l+60GyCzT?= =?utf-8?q?Q9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ICIxSia5hIw7mzsTi/i7P7sJGfvipfxTCkz9m3r3AK8mTExDOBFKAz4?= =?utf-8?q?7W1wwOxepuNhkhdYnkjPWC7mWwwj9fYN06JwtYVXoFIOw+9GXFlhutvwDJ3E1qnMT?= =?utf-8?q?YnWadktTkmcq0FRcxTMZgMIqpo3N4Q0VdaJClxM/IlGnbnl6UBps7Wtz5og4JgKke?= =?utf-8?q?9ABDjuYN207TIfzicH3tPjGxlmEHXtwhSh0XOwOAwGV0gPQ5A3zdjrqFCwxTUnNaa?= =?utf-8?q?49bf3zhzO+NZ+PuLJbcb078rQCIhPLn9qGNJQcxKmWaQLQkhKD2A/4zkOEnTG7qCf?= =?utf-8?q?8VgBl9FhNhoMM3Kswp2H5PJJYc17zfyBFNdxrDKCSiDJKqZacHxJvO61+IG6vhJVr?= =?utf-8?q?I9zLcMxoii/CITwMWy39O/hOmLrQGFIWTA=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CWXP265MB3397.GBRP265.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?vzMv7qus1O6wKEYnkq4Cmws+9Zq5?= =?utf-8?q?k4mw7HFTlJdDTbdkHLlBD6aTaPHdDu0c4IqGdqEdMcBmBzelixQ+nKypVXYDxfvpo?= =?utf-8?q?aYO5Fe8i3xMKYRPeJjFN092+LH/VUYKGQlgwojisH8VXNKYFWtDhIRf9x5wUasfs/?= =?utf-8?q?I43Lf4VvCYtl1DsRyO4UXCWMAuOLE4ft0HkcG6o+zZUMdxRfpbWlDSAldalBe555w?= =?utf-8?q?NkjO2bDrNLNQSJgp5Xl9RtasW1TNnCbtWec8E4PRWzhoiRacwhCnSN0ZyIBBtLgFc?= =?utf-8?q?eBI2ecmaRTWVOC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MR7/8di//X4Bzk+X0x8I8c+5FORR0DgVGXnQC/zYqosPvkfK5xSg3IH5qOfK?= =?utf-8?q?hzAnulRXWUjObSd2lrEzw/1AAIjlqjWBOY/wwJCNbMFSV6RGjVjmpA2oCyJjh34bD?= =?utf-8?q?yJPDNK7n6EPntbgocUrqxt3yd8EGsYzBpCRSk8x8Vj/eyohBY6tdJALw7OfEJVC0T?= =?utf-8?q?+ktf8A2LevFwDe/Qz2jMKK+Wn0TL1ozFiMHttwAF6uYzlPjEQ44giiyfSvpA2vHQo?= =?utf-8?q?Zk081N3eS3+uzFUY3YSJCoMLfjD3LjH7IfXUgdLAsbIMdCaZhnoX/0QW/r4PxtwM/?= =?utf-8?q?0yx6lg7P8X869pR4QvTST6PR1c4qg+62fET0HdtBEztaKJ85FriORTqpHZEKJdt+p?= =?utf-8?q?Mfbi8U6+LNS63szSqw+AThS0O3atDIYO6A=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CWXP265MB3397.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 1e58505b-89f4-4daa-ba67-08dcc7633eea X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Aug 2024 13:13:45.0933 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0d5fd8bb-e8c2-4e0a-8dd5-2c264f7140fe X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 5/duukJF9ysX9LrjX0Ofdu4Yp0ayRgGxJSFO0CU8+6NiKXEPxI2Q3EI9vdPuRvErTVNLU7ujkGTErLmOdkQ6TQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO4P265MB6201 X-OriginatorOrg: imgtec.com X-EXCLAIMER-MD-CONFIG: 15a78312-3e47-46eb-9010-2e54d84a9631 X-Authority-Analysis: v=2.4 cv=MeE+uI/f c=1 sm=1 tr=0 ts=66cf228d cx=c_pps a=6IdplsTJodF3+aqeaEJcqA==:117 a=6IdplsTJodF3+aqeaEJcqA==:17 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=yoJbH4e0A30A:10 a=WnR_qW7rlZcA:10 a=NgoYpvdbvlAA:10 a=r_1tXGB3AAAA:8 a=VwQbUJbxAAAA:8 a=5cLMoERiDscuWAzwkZIA:9 a=QEXdDO2ut3YA:10 a=YoM8tg08yh9GXzwF2s4A:9 a=FfaGCDsud1wA:10 a=t8nPyN_e6usw4ciXM-Pk:22 a=AjGcO6oz07-iQ99wixmX:22 X-Proofpoint-GUID: ZUis_eYqss9TThvFjW_gGvpEZ4hYj79x X-Proofpoint-ORIG-GUID: ZUis_eYqss9TThvFjW_gGvpEZ4hYj79x 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" This caused a measurable memory leak. Although the individual allocations are small, the leaks occurs in a high-usage codepath (remapping or unmapping device memory) so they add up quickly. Signed-off-by: Matt Coster Fixes: ff5f643de0bf ("drm/imagination: Add GEM and VM related code") Cc: stable@vger.kernel.org Reviewed-by: Frank Binns --- drivers/gpu/drm/imagination/pvr_vm.c | 4 ++++ 1 file changed, 4 insertions(+) *op_ctx) } drm_gpuva_unlink(op->remap.unmap->va); + kfree(to_pvr_vm_gpuva(op->remap.unmap->va)); return 0; } diff --git a/drivers/gpu/drm/imagination/pvr_vm.c b/drivers/gpu/drm/imagination/pvr_vm.c index e59517ba039e..97c0f772ed65 100644 --- a/drivers/gpu/drm/imagination/pvr_vm.c +++ b/drivers/gpu/drm/imagination/pvr_vm.c @@ -114,6 +114,8 @@ struct pvr_vm_gpuva { struct drm_gpuva base; }; +#define to_pvr_vm_gpuva(va) container_of_const(va, struct pvr_vm_gpuva, base) + enum pvr_vm_bind_type { PVR_VM_BIND_TYPE_MAP, PVR_VM_BIND_TYPE_UNMAP, @@ -386,6 +388,7 @@ pvr_vm_gpuva_unmap(struct drm_gpuva_op *op, void *op_ctx) drm_gpuva_unmap(&op->unmap); drm_gpuva_unlink(op->unmap.va); + kfree(to_pvr_vm_gpuva(op->unmap.va)); return 0; } @@ -433,6 +436,7 @@ pvr_vm_gpuva_remap(struct drm_gpuva_op *op, void