From patchwork Fri Oct 18 15:41:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Coster X-Patchwork-Id: 13841987 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 17E12D2FFFA for ; Fri, 18 Oct 2024 15:41:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 91F7210E17F; Fri, 18 Oct 2024 15:41:45 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=imgtec.com header.i=@imgtec.com header.b="OYTttFDn"; dkim=pass (1024-bit key; unprotected) header.d=IMGTecCRM.onmicrosoft.com header.i=@IMGTecCRM.onmicrosoft.com header.b="Dd1qWmpy"; dkim-atps=neutral Received: from mx07-00376f01.pphosted.com (mx07-00376f01.pphosted.com [185.132.180.163]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4DE3F10E17F for ; Fri, 18 Oct 2024 15:41:43 +0000 (UTC) Received: from pps.filterd (m0168889.ppops.net [127.0.0.1]) by mx07-00376f01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49IBOtc3029211; Fri, 18 Oct 2024 16:41:26 +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=IihoLvGBawCXUU0DmayHeYLz7wx8GY2G9eF14yEDctg=; b=OYT ttFDnN0RPx0Vi75Ap7OlIa/86/+dK+G6MjAkZnTb/qSmUuJYSXhhoQ1JA77Uo7LE /jpolyBJOQ/9i44J3Vc/9u+YTwk8NJALE+nhDo275iMVWK1TbRw06Fu9Jh5s1mf+ DcEerUfGvn2vq0y6lHDGw1XvC7TZpO2pYwVpH9O3fKUUwOWXgkKHXUNdJ+s+tOzG aHvtoL6+C29YWadxzbDAgjjHus1fvvH++6dx4PpiJ1lSR6n2JNyWw5Ofq7U3+4wh GNQkamvX9B6S8zLzejrgAS52UYjNv4UT5iGZ42/zjcAcJ4i2tEUPUeiDN4R51D9B 7oUNqT17q+36QJeZidQ== Received: from cwxp265cu008.outbound.protection.outlook.com (mail-ukwestazlp17010003.outbound.protection.outlook.com [40.93.68.3]) by mx07-00376f01.pphosted.com (PPS) with ESMTPS id 42a37vb3fy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 18 Oct 2024 16:41:25 +0100 (BST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GsIu7G2eU0CyjJYv3FR1QNg/sXOrCyIktO9HnkZq0qKqBHqVg2GNs1CifJapDNoJgNX96XUzcEiVfvjwHVn9ZHM27xQJegSBBizQStMsdGIIGJYmSVIfpBBBot1fZHyT8iY5UUPoZS9LBjo+J+pJPte4TeEc9C4sIqNBShmv7xyvmcBPz0MB9GMR2UFec38r46VpwaHDxdILSBccWfO4Sz+nyijL3fwfY5N6/kVyul91lkz8mQR4DdkZKX5BncsTkOsiVggnE5coWahPU3i2oRN2XRWiulR/ASEqBDeLDyToMuieMFC8iI0ADc2ezYaiqM+5stTejjsam4udwnkKig== 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=IihoLvGBawCXUU0DmayHeYLz7wx8GY2G9eF14yEDctg=; b=rMb2LPWqHSw/k/WnoqJBlauv9VZLsrgfsQ7kyQHziWm3iEwhbxM4jyiKxxasWCoDlI8r9r8FKVPUzIC7MwTstp9IbJ+dd6kno4EwXYTQj3tacRvzi2V2QM4nww08MLkxfS57psIJ/k19M/xGkDsEXGVMtkQzfpXeZ3gcdIQecXWl8Q+fwIgfMPeMhDmyd5LeWEc9g3JD4Sr/IWBdNXbCBhvYddd8aLQQXt43zDOUT06Fn9lHX3oJ2X9YIEFRWA3izG71sRu82tXCYrKVuNcP+uJGRzmyT0J360rMMkjQyTYQwu2oswHDEGCT4syGyRVUL1LZ/jv3UElXy/Mu4YuwOQ== 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=IihoLvGBawCXUU0DmayHeYLz7wx8GY2G9eF14yEDctg=; b=Dd1qWmpyfn0Bm5Gy9+vKNT4DazwxfsTAUid2BDO4fVJlXcm/0rJvsPqHAt1S9UAMXJRO0X6smrXkrvYar5YJM8mBWuVp6Pv4J24r1tfBPzKNcnu0RdS0OrrkKTcHBCrcj5HpgOBJpeTrT/WwfbF9oGCmCuc/9mXK9F6FUzGSrpg= Received: from CWXP265MB3397.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:e7::8) by CWLP265MB2259.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:6b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.18; Fri, 18 Oct 2024 15:41:22 +0000 Received: from CWXP265MB3397.GBRP265.PROD.OUTLOOK.COM ([fe80::8e9d:6b2f:9881:1e15]) by CWXP265MB3397.GBRP265.PROD.OUTLOOK.COM ([fe80::8e9d:6b2f:9881:1e15%6]) with mapi id 15.20.8069.020; Fri, 18 Oct 2024 15:41:22 +0000 From: Matt Coster To: "dri-devel@lists.freedesktop.org" CC: Brendan King , Frank Binns , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , "linux-kernel@vger.kernel.org" Subject: [PATCH v3 0/2] drm/imagination: Break an obejct reference loop Thread-Topic: [PATCH v3 0/2] drm/imagination: Break an obejct reference loop Thread-Index: AQHbIXQuboC/3/MB806N35xCePd1hw== Date: Fri, 18 Oct 2024 15:41:22 +0000 Message-ID: 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_|CWLP265MB2259:EE_ x-ms-office365-filtering-correlation-id: 47348a7b-3458-4065-5891-08dcef8b515e x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|366016|376014|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?/jAQOXh/WQ3tgQOE3EwqV/IRNHMdO1D?= =?utf-8?q?chcS7/qSfv7OSHSnbueihOA4mfDEBjybLbqkkIpLFQ08kbnd2OWTZGwrKDFW+EKo8?= =?utf-8?q?T+6Z3OOKBoLbjUehW4hNE9v45HvjNzmXOJtwn10ArAdemY6cZb1cRmVv3hiQIXakz?= =?utf-8?q?meFCobQ9nsCD0EGIuJTst7/ZGToZkC0PGseOIqa5ibRM5/5BOFT6XJOXSpPlnyXh1?= =?utf-8?q?bAo/sMHLjWh6IjzZbACIFrx11cw+fWawTUm9IaW+Ed4xTipDRwz6nHKubar9VS/eN?= =?utf-8?q?JSEQnSNpFISWBbKeE270JFE8MrYmC4n3T5N/lwqsv/PsC1rw8dMKZJC+l3H6TTZvt?= =?utf-8?q?gvcggkEB9zAud/6pB6IgSHiEzEGcc0/hAQxUwQsWr+K5Cc6l4Iayso62fzrSPkUJP?= =?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3zLSOeBIHYzpSpZaCDEuSb5qIY+8DKm55AwJ51Lz6VcBkMBX/dghjfeQO0?= =?utf-8?q?PB0RKCF5HVaF?= 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)(1800799024)(366016)(376014)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?XE1PVRrc7YgPlFdrYD6vIyK093dg?= =?utf-8?q?6SsbB//x67EqgS63zdw7Y4A/ZqGL/CDR6W1nPD4nEVDM/LLYOpx/7s7dKdpWrvrzx?= =?utf-8?q?HNqn2AETsAeQxJycFHwKfKqoLRDOYtXmrVdublfAKZFogVfVy7vgheKJEzvg+wOsR?= =?utf-8?q?3XOneZRzPZuFrqeJk10eFrKJcqAp6tg6UcvR6ZWqiMgfnvU6hu22+Ym5dwCNaq29G?= =?utf-8?q?S/vYxiWTTuKqV/aMHNgN77fYImfHSmGylQkghtP3uJzfdWOc9tnkXYPf0U+dlAluj?= =?utf-8?q?A9gq+N0t+qIk41asPa0EeUYKr/8QFT/yO7+PWpqZUmCe7BkmCEsrducVREg4sXcao?= =?utf-8?q?zj6gT2+Skh5mV88+IOIa3xkewulwU7qyk0en5EOhur9BFPMkCxyMAtTI4f2gxOUGG?= =?utf-8?q?5ChUc1c37JSsC19zCSX3hQ3yga9+EHAfsgZzuQUCZxJnXiCTWNMu0EWKiqirzjKBt?= =?utf-8?q?3fR0fEvXg3CahDo+K/C5UVHLAqY13hRWyrtC0lpUOc7vP10AW6mL+o9cnogfA4c5D?= =?utf-8?q?DMCuH7skTyGUN+PJdt9jEDWS2IGXmHJVQ/1gxDL/YSUyV7j9SL2qjRgtxX/Kfj9CR?= =?utf-8?q?v2kdzTL3azGDMF2xC0PbA8oGM1LXFgCewr42hIYEf61+2G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jCpaVWbkwEWc9lENCrgnPWowA2EMYaPa6ZUR?= =?utf-8?q?xVTEW+ZA/VSr+dE9oobkjGZcu5vGVTzIZQ=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: imgtec.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CWXP265MB3397.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 47348a7b-3458-4065-5891-08dcef8b515e X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Oct 2024 15:41:22.3948 (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: /pw0RkEZnZrhlmUlbjXnXvE+yrnn4jPWjvGaoJo48GA2w99PzrZiqTxjVj8x9JmemM3Y/PiavgnpUZ5aJys0bw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP265MB2259 X-Proofpoint-GUID: 5k-55ST8QpNpCRmMVHOMG_2mXQUmhg5r X-Authority-Analysis: v=2.4 cv=N5V7FH9B c=1 sm=1 tr=0 ts=671281a6 cx=c_pps a=Du42DVBbjaS4S3NNO6dabQ==:117 a=Ol13hO9ccFRV9qXi2t6ftBPywas=:19 a=xqWC_Br6kY4A:10 a=DAUX931o1VcA:10 a=WnR_qW7rlZcA:10 a=NgoYpvdbvlAA:10 a=VwQbUJbxAAAA:8 a=r_1tXGB3AAAA:8 a=Eu8HcYkoJM88dJRg7BoA:9 a=QEXdDO2ut3YA:10 a=4dGhhBZ303MdWhY03bQA:9 a=FfaGCDsud1wA:10 a=t8nPyN_e6usw4ciXM-Pk:22 X-Proofpoint-ORIG-GUID: 5k-55ST8QpNpCRmMVHOMG_2mXQUmhg5r 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" When remaining resources are being cleaned up on driver close, outstanding VM mappings may result in resources being leaked, due to an object reference loop, as shown below, with each object (or set of objects) referencing the object below it: PVR GEM Object GPU scheduler "finished" fence GPU scheduler "scheduled" fence PVR driver "done" fence PVR Context PVR VM Context PVR VM Mappings PVR GEM Object The reference that the PVR VM Context has on the VM mappings is a soft one, in the sense that the freeing of outstanding VM mappings is done as part of VM context destruction; no reference counts are involved, as is the case for all the other references in the loop. To break the reference loop during cleanup, free the outstanding VM mappings before destroying the PVR Context associated with the VM context. This is facilitated by tracking the live contexts associated with each list, implemented in a separate patch to make the main patch cleaner and easier to grok. --- Changes in v1 -> v2: - [PATCH 1/2] Add justification to the commit message so it stands on its own (e.g. during bisect) Changes in v2 -> v3: - [ALL] Add Frank's Rb [1][2] - [ALL] Add Cc: stable tag [1]: https://lore.kernel.org/dri-devel/1a206b08485a1ebea0aeff5306c0f5b6eb7c315d.camel@imgtec.com/ [2]: https://lore.kernel.org/dri-devel/b75e658cc5ce9ac24df2c31c1a6fd798a5f3a87f.camel@imgtec.com/ --- Brendan King (2): drm/imagination: Add a per-file PVR context list drm/imagination: Break an object reference loop drivers/gpu/drm/imagination/pvr_context.c | 33 +++++++++++++++++++++++ drivers/gpu/drm/imagination/pvr_context.h | 21 +++++++++++++++ drivers/gpu/drm/imagination/pvr_device.h | 10 +++++++ drivers/gpu/drm/imagination/pvr_drv.c | 3 +++ drivers/gpu/drm/imagination/pvr_vm.c | 22 ++++++++++++--- drivers/gpu/drm/imagination/pvr_vm.h | 1 + 6 files changed, 86 insertions(+), 4 deletions(-) base-commit: 83f000784844cb9d4669ef1a3366479db3197b33