From mboxrd@z Thu Jan 1 00:00:00 1970 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 B98E9CF11CF for ; Thu, 10 Oct 2024 11:03:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8243210E8CD; Thu, 10 Oct 2024 11:03:19 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="ZL9M+D0/"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id 56F0A10E8CD for ; Thu, 10 Oct 2024 11:03:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728558199; x=1760094199; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=Q0ws/Nwz+o4rIK6L/vXqVNBF4s4a1nL1ELtf9a+bmwM=; b=ZL9M+D0/hqxsp7dR1wLd9NClO8P3xZc3KpWJSi2B5Wj0Fg2xKBgYA/Lf HMkYvqoRhBocR5gQuHwmxp+DO9P/yrFU7ZcZE5q+8bQB4oV7KDCACA/VI O5u7TYH0cXi/xg4aKEZ+jbAFGTF/aCh2RkZnIF28f6FPuXg/gzQVI4CN5 AK9s7zoDnSxETSpPjivf8Ym7/MdwjoV1JlGXTTFf9ZcY48dIYIRF73e2v 4y3IXZ82kS5G+8/VotCCX3sMYx/mmSlCZeumggdWhI5QrMynZLrvvU8u5 AZN9VO4MsGVfPYnNA/OLwrkLQ/H5VmQLZqKU1boS4Sy0gaZRlN47s4JDv Q==; X-CSE-ConnectionGUID: RpTkVx1WSzK53o00OEABaQ== X-CSE-MsgGUID: tE+n1bPbTiC89oL9SFV27Q== X-IronPort-AV: E=McAfee;i="6700,10204,11220"; a="28022870" X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="28022870" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2024 04:03:19 -0700 X-CSE-ConnectionGUID: ULzXcoPpQAOi1Wo5MaJ5xw== X-CSE-MsgGUID: dYzqONQ0R1qp8hbOYudbaA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,192,1725346800"; d="scan'208";a="80564441" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmviesa003.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 10 Oct 2024 04:03:18 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 10 Oct 2024 04:03:17 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 10 Oct 2024 04:03:17 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 10 Oct 2024 04:03:17 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.49) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 10 Oct 2024 04:03:16 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OejP8FvfnRnDPfY4VErHbwcNKm+H0Mz4dQ2qXDBu44DIr1l8njxziegrUSMQYL+5KWbR3q0pQJvIVmzJL1pOFcOIYJU5DFMFRvvkt1pgStuDDen612VIUJXiRe8VLymREfWushMfy4GntQ+qqEInc8coX2mtuYJQuTDa/J8pBGklZXAdPGaAO3Maw6ObiM5aW8kp+hom8l/jUoqDFZcnjKIvj1Koi9Zh+Bos811Oz+OoNAAocNTpcKYnETiLbga6kmvX6oirAJNVVsfCyJ8cy32jmRN0JCWvU3kkSR/iekMsr5qlN753aHD6s5/87QonK0EjN9wPQY3Mu5Bll0Bszw== 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=jJ4NsAtb0nhgy85uz/pMnB85LY28jbY7CmAJGaFB8iU=; b=HhflZBoj4EUHaRugGD50+nyDy/xVUMBQPGFK/BWgOV0dMEXlaL15bIH7UTPOOqPZMcn4ERx9PqUDjZIdHUo51N8mOspDCfR0HP/cM93JseyuZJEkY9r3uN4wqm6/UVcz3To/2cgqpEmbelRn7h2h6W8CC5h8KFsmRI2dMRAzhiW5BotiC68mv43eGUnhRjXFFJicrnuyJ2TmsOkoF9xoMD2K0sVGFv1jZUjF9ZbQzjIDB7bqIc7acTYFXLktt0hUGgMDYMRpkRSvV5CIW7527+VbJGyvOwXodxnvm+S7VWFLiT+Ddhrezv5a58BjDNUsb0909qsyqJNh/eNiwV++uA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from PH8PR11MB6974.namprd11.prod.outlook.com (2603:10b6:510:225::16) by PH7PR11MB7605.namprd11.prod.outlook.com (2603:10b6:510:277::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Thu, 10 Oct 2024 11:03:14 +0000 Received: from PH8PR11MB6974.namprd11.prod.outlook.com ([fe80::c0b4:f63a:9c33:ec4a]) by PH8PR11MB6974.namprd11.prod.outlook.com ([fe80::c0b4:f63a:9c33:ec4a%4]) with mapi id 15.20.8026.020; Thu, 10 Oct 2024 11:03:14 +0000 Date: Thu, 10 Oct 2024 16:33:08 +0530 From: "Vivekanandan, Balasubramani" To: Matthew Brost , Lucas De Marchi CC: , Niranjana Vishwanathapura , Tejas Upadhyay Subject: Re: [PATCH v2 2/2] drm/xe: Use the filelist from drm for ccs_mode change Message-ID: References: <20241008073628.377433-1-balasubramani.vivekanandan@intel.com> <20241008073628.377433-3-balasubramani.vivekanandan@intel.com> Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: MA1PR01CA0181.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::19) To PH8PR11MB6974.namprd11.prod.outlook.com (2603:10b6:510:225::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH8PR11MB6974:EE_|PH7PR11MB7605:EE_ X-MS-Office365-Filtering-Correlation-Id: 4c92b7e0-453b-4769-d244-08dce91b2330 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?YXdZYXRWZmdvWXZRQm9HeEtuRWtEY2REbWRob0J5d1FROHg4eGpmcjY2TlVh?= =?utf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I?= =?utf-8?B?TEdRdkJ5UWNwT1drSnVqYnYxSHJtaFNXYnYyUkJjbXB6anpwZGtwbUkvWldW?= =?utf-8?B?NVl6SUNFMThJWld6a25jTlRodW1Bcm5KZDBSaG4rL0x5NlpqMWJLOFZlOXFx?= =?utf-8?B?QTBabW5qK2t1TEtsWTNSeEhPSzhGUTBWRzdmL3BYKzNETG5UZ0lmV0cxenJp?= =?utf-8?B?ejdOZWRmTjhPMmlrZDYrdjBic3BuZGF1aG90Q1Z6U2YyVFJ3SkRac0RGcXF0?= =?utf-8?B?ODFFNnU1YytsOFQrTHJIcDVVdjI0V3JOSHZUTkI2aU9jN2dyVyt5S3pPSG9S?= =?utf-8?B?d250b0t0bkdrblFuT2duaHkramllS0VWK1RYQVRrRDgrQlNwN0FxN1FKSDBC?= =?utf-8?B?VXFYdkFQTVA5T29MaUdKbkkxU0ZhOWt4UXlIdUx4QjY0Um42WElzYlVhS2tv?= =?utf-8?B?dk1GK3NJaHVEWmhzTU9DVzFpb3JHNjNRZzBHek05WEhaamxBZTFLN3lRemNZ?= =?utf-8?Q?2dydxQH/fv+QxiRJ7Er6CTQ=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 4c92b7e0-453b-4769-d244-08dce91b2330 X-MS-Exchange-CrossTenant-AuthSource: PH8PR11MB6974.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2024 11:03:14.7181 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jKw3l03xQwv3sU+LF5vUT1wyN9h1BIbyy+nIM+Je8TpajK+nNvsyU4Ohmld7DuJR3p88kKJus5T8lUsVm78DtLmgVt5AiKJ0QP5p/tmo8NZUzMIzMOe1U02xhATWCn+M X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB7605 X-OriginatorOrg: intel.com X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" On 08.10.2024 18:00, Matthew Brost wrote: > On Tue, Oct 08, 2024 at 05:24:32PM +0000, Matthew Brost wrote: > > On Tue, Oct 08, 2024 at 11:55:03AM -0500, Lucas De Marchi wrote: > > > On Tue, Oct 08, 2024 at 03:42:09PM +0000, Matthew Brost wrote: > > > > On Tue, Oct 08, 2024 at 10:20:15AM -0500, Lucas De Marchi wrote: > > > > > On Tue, Oct 08, 2024 at 02:54:19PM +0000, Matthew Brost wrote: > > > > > > On Tue, Oct 08, 2024 at 01:06:28PM +0530, Balasubramani Vivekanandan wrote: > > > > > > > Drop the exclusive client count tracking and use the filelist from the > > > > > > > drm to track the active clients. This also ensures the clients created > > > > > > > internally by the driver won't block changing the ccs mode. > > > > > > > > > > > > > > Fixes: ce8c161cbad4 ("drm/xe: Add ref counting for xe_file") > > > > > > > > > > > > Is this really fixing anything. As far as I can tell nothing upstream > > > > > > opens a file internally (i.e. xe_file_open) is never called directly. > > > > > > > > > > should fix this case: > > > > > > > > > > open() > > > > > close() > > > > > <---- race here > > > > > change_ccs_mode() > > > > > > > > > > because the close is not completely sync - the cleanup where the > > > > > previous number of clients is decremented is executed too late and > > > > > subject to a race fixed here. > > > > > > > > > > > > > Ah, ok. But then IMO just move the clients.count decrement to > > > > xe_file_close. I try to preach solid locking / layering and this seems > > > > to go against this idea. > > > > > > why do you want to track the exact same thing in 2 ways, one in drm and > > > the other in xe? "Are there clients connected?" is something drm_file > > > answer and doesn't need to be duplicated in the individual drivers. > > > > > > > Well layering, making assumptions about the file list means, and not > > randomly deciding what we can and can't do with locks we don't own. > > > > I looked at this a bit more, if we want to do it this way then I think > at a minimum we need a drm helper for this. > > e.g., > > bool drm_device_user_clients_open(struct drm_device *dev) > { > lockdep_assert(&dev->filelist_mutex); > > return !!list_empty(&dev->filelist); > } Still the driver would be required to use the filelist_mutex outside the drm layer. So will not solve the layering problem completely. Otherwise we can define two helper functions in drm, the first one would check there are no open files and returns true holding the mutex. The second function can be used to release the mutex. Does it sound too invasive? Regards, Bala > > Matt > > > > At least it's also used for similar reasons in amdgpu and vmwgfx: > > > > > > $ git grep -l -e "->filelist" -- drivers/gpu/drm/ > > > drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c > > > drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c > > > drivers/gpu/drm/drm_client.c > > > drivers/gpu/drm/drm_debugfs.c > > > drivers/gpu/drm/drm_drv.c > > > drivers/gpu/drm/drm_file.c > > > drivers/gpu/drm/vmwgfx/vmwgfx_gem.c > > > > > > > The AMD / VMWGFX usage certainly looks wrong to me. If the file list was > > meant to be traversed by drivers there should be an exported iterator > > IMO. > > > > Matt > > > > > > > > Lucas De Marchi