From patchwork Wed Feb 12 20:05:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 13972402 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 A18C7C021A0 for ; Wed, 12 Feb 2025 20:06:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB11510E989; Wed, 12 Feb 2025 20:06:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="fo7EFa9X"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2DC8B10E97F for ; Wed, 12 Feb 2025 20:06:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739390768; x=1770926768; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SMq3tRylkjXeGIrAENWvMD6N50P9AHGv6CJDNT0dJM0=; b=fo7EFa9Xa56IuCfRSRqVIbDKnPHunJLp/uN/Iohl1JlzPEGxvzdg2U04 ZytHBSxfulY+zaKnTP2HHMxwdo2/1oqkrAImzPOLhJHnmd5sH6mvPuqMa M9Rl2jgZIY+PXz7QRBfu/+o/0AsSNW2KO2u5KtSNGJ6bzwyyLUfmIlITU ot3he3Lz4lN38vtGErJdqJlvm6FsLJykMcddecSDjxnnqMjuNyHKQ/CGw Wt1DK8YpexyDuw1o2/HxdqoHA5GefgKAVqulYCJ+XuAPmudAXOMxcp5im CNxYxIbw6/QLnvTZlyjWkaty9HJzxM0QPT4zZu3ulZmglJZR+/UcA9wql A==; X-CSE-ConnectionGUID: bnxqS8GzTOquoF+jJMqbPQ== X-CSE-MsgGUID: Xt45kivaQM6kp1fpkzOm+w== X-IronPort-AV: E=McAfee;i="6700,10204,11343"; a="50718490" X-IronPort-AV: E=Sophos;i="6.13,280,1732608000"; d="scan'208";a="50718490" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 12:06:07 -0800 X-CSE-ConnectionGUID: XsG6tWzXQ22ft0Xl+AHlRg== X-CSE-MsgGUID: VSyvEcdoQzWlgxLF20YJ7A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,280,1732608000"; d="scan'208";a="118010754" Received: from lucas-s2600cw.jf.intel.com ([10.165.21.196]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 12:06:07 -0800 From: Lucas De Marchi To: linux-kernel@vger.kernel.org Cc: Rodrigo Vivi , dri-devel@lists.freedesktop.org, Danilo Krummrich , "Rafael J. Wysocki" , Greg Kroah-Hartman , Lucas De Marchi Subject: [PATCH 1/6] drivers: base: devres: Allow to release group on device release Date: Wed, 12 Feb 2025 12:05:37 -0800 Message-ID: <20250212200542.515493-2-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250212200542.515493-1-lucas.demarchi@intel.com> References: <20250212200542.515493-1-lucas.demarchi@intel.com> 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" When releasing a device, if the release action causes a group to be released, a warning is emitted because it can't find the group. This happens because devres_release_all() moves the entire list to a todo list and also move the group markers. Considering r* normal resource nodes and g1 a group resource node: g1 -----------. v v r1 -> r2 -> g1[0] -> r3-> g[1] -> r4 After devres_release_all(), dev->devres_head becomes empty and the todo list it iterates on becomes: g1 v r1 -> r2 -> r3-> r4 -> g1[0] When a call to component_del() is made and takes down the aggregate device, a warning like this happen: RIP: 0010:devres_release_group+0x362/0x530 ... Call Trace: component_unbind+0x156/0x380 component_unbind_all+0x1d0/0x270 mei_component_master_unbind+0x28/0x80 [mei_hdcp] take_down_aggregate_device+0xc1/0x160 component_del+0x1c6/0x3e0 intel_hdcp_component_fini+0xf1/0x170 [xe] xe_display_fini+0x1e/0x40 [xe] Because the devres group corresponding to the hdcp component cannot be found. Just ignore this corner case: if the dev->devres_head is empty and the caller is trying to remove a group, it's likely in the process of device cleanup so just ignore it instead of warning. Signed-off-by: Lucas De Marchi Acked-by: Greg Kroah-Hartman --- The check for just an empty devres_head seems simple and sufficient, although the caller of devres_release_group() can still shoot its own foot. I thought about a flag on dev to check it's being removed, but I want to know others' opinions first. drivers/base/devres.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/base/devres.c b/drivers/base/devres.c index 93e7779ef21e8..b955a2f9520bf 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -687,6 +687,13 @@ int devres_release_group(struct device *dev, void *id) spin_unlock_irqrestore(&dev->devres_lock, flags); release_nodes(dev, &todo); + } else if (list_empty(&dev->devres_head)) { + /* + * dev is probably dying via devres_release_all(): groups + * have already been removed and are on the process of + * being released - don't touch and don't warn. + */ + spin_unlock_irqrestore(&dev->devres_lock, flags); } else { WARN_ON(1); spin_unlock_irqrestore(&dev->devres_lock, flags); From patchwork Wed Feb 12 20:05:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 13972400 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 BB9DFC02198 for ; Wed, 12 Feb 2025 20:06:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8831010E980; Wed, 12 Feb 2025 20:06:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="dcmngGSf"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4FEBF10E97E for ; Wed, 12 Feb 2025 20:06:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739390768; x=1770926768; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UrP4+S/PJRRzsNR6LIvFEhiK0LIXEoP6w6Tk9R2XVTE=; b=dcmngGSflN6VTQgLCm8nQsV9E3+zDl2oI/hXbtQ5hGgsOflfnRdgGSqD m4owDG4vgKrvqWKZhO73SFVTKJY8Lp5ZL5DU9fBUxM36dlJhw0m8zp0ED zzJwutuDbaiKXpAw9NAr9h0tPBpVTP0HtxLOsykNMES8Yl5EJ3aQQ626H CWP8i9JkwomcHKqnUQ8aOH3jkwTb6d0YMhG+4TszeTa0JWGaoTaBQrzk6 EWaMV83S6NLfSgXB7Dc/dcNJLY3MSRq2bFcYTbbl43BgIuPoGdyacTmaC cJH0GJNJqP9/fvipXJwGdv+OKQWAAgv6QPCLz1RFQn7JZXVH2tcmLHJA0 Q==; X-CSE-ConnectionGUID: ptEu/jcORbuW3CsMjcYQnQ== X-CSE-MsgGUID: pj3/o3XyRGWSc0aLM9Ilsg== X-IronPort-AV: E=McAfee;i="6700,10204,11343"; a="50718494" X-IronPort-AV: E=Sophos;i="6.13,280,1732608000"; d="scan'208";a="50718494" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 12:06:07 -0800 X-CSE-ConnectionGUID: jRDc34lJSaiZwqpzTgQxng== X-CSE-MsgGUID: J2U+vyrnTMK/DUoGZf9pkQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,280,1732608000"; d="scan'208";a="118010757" Received: from lucas-s2600cw.jf.intel.com ([10.165.21.196]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 12:06:07 -0800 From: Lucas De Marchi To: linux-kernel@vger.kernel.org Cc: Rodrigo Vivi , dri-devel@lists.freedesktop.org, Danilo Krummrich , "Rafael J. Wysocki" , Greg Kroah-Hartman , Lucas De Marchi Subject: [PATCH 2/6] drivers: base: devres: Fix find_group() documentation Date: Wed, 12 Feb 2025 12:05:38 -0800 Message-ID: <20250212200542.515493-3-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250212200542.515493-1-lucas.demarchi@intel.com> References: <20250212200542.515493-1-lucas.demarchi@intel.com> 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" It returns the last open group, not the last group. Signed-off-by: Lucas De Marchi Acked-by: Greg Kroah-Hartman --- drivers/base/devres.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/base/devres.c b/drivers/base/devres.c index b955a2f9520bf..d8a733ea5e1ac 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -576,7 +576,10 @@ void *devres_open_group(struct device *dev, void *id, gfp_t gfp) } EXPORT_SYMBOL_GPL(devres_open_group); -/* Find devres group with ID @id. If @id is NULL, look for the latest. */ +/* + * Find devres group with ID @id. If @id is NULL, look for the latest open + * group. + */ static struct devres_group *find_group(struct device *dev, void *id) { struct devres_node *node; From patchwork Wed Feb 12 20:05:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 13972398 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 1E764C021A4 for ; Wed, 12 Feb 2025 20:06:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7DC9510E97F; Wed, 12 Feb 2025 20:06:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Ou0Q1D5E"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 866DC10E97E for ; Wed, 12 Feb 2025 20:06:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739390768; x=1770926768; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=asPsjfJ93s8xZX8uMGYNQdUgRg6kPjTaMYqujLFIiio=; b=Ou0Q1D5EYe0Waif+KBW5CwG7nHP3KRiu4TJ/G1QTqgWstQA7iR9V0Bhh yAZl5s6FW9l6V8ZgfmRAqhPoJqDpGgvYbycnUGfSwQ1yGXK2lRf/6Zz73 2wMdaEPgEG+HfbX+WIaqQ1kxoIPcZ+viHXc1qmeNvjKl62qklJA1o2CMT krKIA90dNku8fRvB1AKeFDrhDXYexrS+vmMNWE4KCC21v1x8DOsuBwaSA worl7K4Lj4ClCE2ijah0NGmLyyrx+Cxfb5pWSRvDLsWg3OJG90G+8KNW6 UEeO6uXC138HIGGZm+dP2AsLIR/73k6ojSmLaZU0hEUbZsYf7TOBNXUFE w==; X-CSE-ConnectionGUID: QxDt8XuWS2yjQegM6AgU8A== X-CSE-MsgGUID: Apkhn7lVRReMtnN4e26eUw== X-IronPort-AV: E=McAfee;i="6700,10204,11343"; a="50718498" X-IronPort-AV: E=Sophos;i="6.13,280,1732608000"; d="scan'208";a="50718498" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 12:06:08 -0800 X-CSE-ConnectionGUID: mziKP4TcTWyd52lsoa6x3g== X-CSE-MsgGUID: e+SHg10+Sh+ngqOWmjOKpw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,280,1732608000"; d="scan'208";a="118010760" Received: from lucas-s2600cw.jf.intel.com ([10.165.21.196]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 12:06:08 -0800 From: Lucas De Marchi To: linux-kernel@vger.kernel.org Cc: Rodrigo Vivi , dri-devel@lists.freedesktop.org, Danilo Krummrich , "Rafael J. Wysocki" , Greg Kroah-Hartman , Lucas De Marchi Subject: [PATCH 3/6] drivers: base: component: Add debug message for unbind Date: Wed, 12 Feb 2025 12:05:39 -0800 Message-ID: <20250212200542.515493-4-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250212200542.515493-1-lucas.demarchi@intel.com> References: <20250212200542.515493-1-lucas.demarchi@intel.com> 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" Like when binding component, add a debug message to the unbinding case to make it easy to track the lifecycle. This also includes the component pointer since that is used to open a group in devres, making it easier to track the resources. Signed-off-by: Lucas De Marchi Acked-by: Greg Kroah-Hartman --- drivers/base/component.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/base/component.c b/drivers/base/component.c index 741497324d78a..5d10600bbc25e 100644 --- a/drivers/base/component.c +++ b/drivers/base/component.c @@ -574,6 +574,9 @@ static void component_unbind(struct component *component, { WARN_ON(!component->bound); + dev_dbg(adev->parent, "unbinding %s component %p (ops %ps)\n", + dev_name(component->dev), component, component->ops); + if (component->ops && component->ops->unbind) component->ops->unbind(component->dev, adev->parent, data); component->bound = false; From patchwork Wed Feb 12 20:05:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 13972399 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 8E815C021A0 for ; Wed, 12 Feb 2025 20:06:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8E80C10E984; Wed, 12 Feb 2025 20:06:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="eVAA95x4"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id B783F10E97E for ; Wed, 12 Feb 2025 20:06:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739390768; x=1770926768; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XTmQJPQ5vx5r/L8CDAB6q56EodWAZR1tsyiCvS/EAl4=; b=eVAA95x4DxcEHjLmU6I42W5YCzufCkAZYw4lEH18OcF6WOpt98fNMVW2 mHGMznI3K/H+cfVnmifKSseJWIVQrP2MojgAgkFnEiRf+gAdx3unGhd9Y 3kYXB+sUqZqCRb93DPSRYihvrqiiocNftpdOvX7KeHtfoC/NxRSdC3mLI xjlTfVDH+9rNRcvI3yJrg+wxMINojfKZFW7XR09dNyJcJtQVXrKH7etVF 47QytfWVs/FGcn2rXtINmmAn019mCxJuec4uMzx74kpZGb+cz3CQEITk8 U48Yb7npIWVrSgmty2sNTPR+jkQkc8z1+jq+gJpkjrfKBx0kWPiywa3Vy A==; X-CSE-ConnectionGUID: G9/UqOYkSuCi3aYvSoiGNA== X-CSE-MsgGUID: RhJgSP0HSreOterY/zKBfw== X-IronPort-AV: E=McAfee;i="6700,10204,11343"; a="50718503" X-IronPort-AV: E=Sophos;i="6.13,280,1732608000"; d="scan'208";a="50718503" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 12:06:08 -0800 X-CSE-ConnectionGUID: COHXL0iVRKaHteebi5GiEA== X-CSE-MsgGUID: yztDUGpISz2+Sf8zHaaz4Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,280,1732608000"; d="scan'208";a="118010764" Received: from lucas-s2600cw.jf.intel.com ([10.165.21.196]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 12:06:08 -0800 From: Lucas De Marchi To: linux-kernel@vger.kernel.org Cc: Rodrigo Vivi , dri-devel@lists.freedesktop.org, Danilo Krummrich , "Rafael J. Wysocki" , Greg Kroah-Hartman , Lucas De Marchi Subject: [PATCH 4/6] drm/xe: Stop setting drvdata to NULL Date: Wed, 12 Feb 2025 12:05:40 -0800 Message-ID: <20250212200542.515493-5-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250212200542.515493-1-lucas.demarchi@intel.com> References: <20250212200542.515493-1-lucas.demarchi@intel.com> 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" PCI subsystem is not supposed to call the remove() function when probe fails and doesn't need a protection for that. The only places checking for NULL drvdata, is on 2 sysfs files and they shouldn't be needed since the files are removed and reads on open fds just return an error. Remove the setting to NULL so it's possible to obtain the xe pointer from callbacks like the component unbind from device_unbind_cleanup(), i.e. after xe_pci_remove() already finished. Signed-off-by: Lucas De Marchi --- drivers/gpu/drm/xe/xe_device_sysfs.c | 6 ------ drivers/gpu/drm/xe/xe_pci.c | 7 +------ 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_device_sysfs.c b/drivers/gpu/drm/xe/xe_device_sysfs.c index 7375937934fae..7efbd4c52791c 100644 --- a/drivers/gpu/drm/xe/xe_device_sysfs.c +++ b/drivers/gpu/drm/xe/xe_device_sysfs.c @@ -32,9 +32,6 @@ vram_d3cold_threshold_show(struct device *dev, struct xe_device *xe = pdev_to_xe_device(pdev); int ret; - if (!xe) - return -EINVAL; - xe_pm_runtime_get(xe); ret = sysfs_emit(buf, "%d\n", xe->d3cold.vram_threshold); xe_pm_runtime_put(xe); @@ -51,9 +48,6 @@ vram_d3cold_threshold_store(struct device *dev, struct device_attribute *attr, u32 vram_d3cold_threshold; int ret; - if (!xe) - return -EINVAL; - ret = kstrtou32(buff, 0, &vram_d3cold_threshold); if (ret) return ret; diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c index 70b697fde5b96..41ec6825b9bcc 100644 --- a/drivers/gpu/drm/xe/xe_pci.c +++ b/drivers/gpu/drm/xe/xe_pci.c @@ -770,11 +770,7 @@ static int xe_info_init(struct xe_device *xe, static void xe_pci_remove(struct pci_dev *pdev) { - struct xe_device *xe; - - xe = pdev_to_xe_device(pdev); - if (!xe) /* driver load aborted, nothing to cleanup */ - return; + struct xe_device *xe = pdev_to_xe_device(pdev); if (IS_SRIOV_PF(xe)) xe_pci_sriov_configure(pdev, 0); @@ -784,7 +780,6 @@ static void xe_pci_remove(struct pci_dev *pdev) xe_device_remove(xe); xe_pm_runtime_fini(xe); - pci_set_drvdata(pdev, NULL); } /* From patchwork Wed Feb 12 20:05:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 13972403 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 24AB3C02198 for ; Wed, 12 Feb 2025 20:06:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 833FD10E98A; Wed, 12 Feb 2025 20:06:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="m2FDq+Ke"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE57610E97F for ; Wed, 12 Feb 2025 20:06:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739390769; x=1770926769; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eRnfdU2vmfJPGvUWDmysQE9CdXMXytxNB8DSsopwuTM=; b=m2FDq+Ke3dgBF6HkH7z+iCYmFW06ZleWCP05uyPOmfcu3dqBW/XJnX5M CC9rj80BFjyJRG/8syt6pOhfjwOqh43HrOYcAaGSvQyySs6NQfej3RimU oJzhNoNGc4AC+zoVhn8RZBtSMwowelE2hnmj2QPw35066PZoaerrdy9bk ZxlxJAXGN9qcqjt6zWoogXID/uefNh8jJDucCCwe80SKFU/gOR9dTUrCx k4t+X8OzAohW2jnAGamcUT4U/IueWDbeqQd//3IArhNkhSarbzleaBFUW FLNN+6EGmJ5252rFerjLOhbKELJHfm/apPT3m27iyWO1LzZKwpvj58dFB A==; X-CSE-ConnectionGUID: t6uYCyB3QNmNW0y8oTAYOA== X-CSE-MsgGUID: Rvo+zPQsRquVxhY9rypAyw== X-IronPort-AV: E=McAfee;i="6700,10204,11343"; a="50718507" X-IronPort-AV: E=Sophos;i="6.13,280,1732608000"; d="scan'208";a="50718507" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 12:06:08 -0800 X-CSE-ConnectionGUID: QyREsbHrRkazVNBE+qYUaA== X-CSE-MsgGUID: s2C2m5g4TBiX9UjAq70xYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,280,1732608000"; d="scan'208";a="118010767" Received: from lucas-s2600cw.jf.intel.com ([10.165.21.196]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 12:06:08 -0800 From: Lucas De Marchi To: linux-kernel@vger.kernel.org Cc: Rodrigo Vivi , dri-devel@lists.freedesktop.org, Danilo Krummrich , "Rafael J. Wysocki" , Greg Kroah-Hartman , Lucas De Marchi Subject: [PATCH 5/6] drm/xe: Switch from xe to devm actions Date: Wed, 12 Feb 2025 12:05:41 -0800 Message-ID: <20250212200542.515493-6-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250212200542.515493-1-lucas.demarchi@intel.com> References: <20250212200542.515493-1-lucas.demarchi@intel.com> 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" Now that component drivers are compatible with devm, switch to using it instead of our own. Signed-off-by: Lucas De Marchi --- drivers/gpu/drm/xe/display/xe_display.c | 4 ++-- drivers/gpu/drm/xe/xe_gsc_proxy.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/xe/display/xe_display.c b/drivers/gpu/drm/xe/display/xe_display.c index bdcc56e51433f..302f533af037d 100644 --- a/drivers/gpu/drm/xe/display/xe_display.c +++ b/drivers/gpu/drm/xe/display/xe_display.c @@ -161,7 +161,7 @@ int xe_display_init_early(struct xe_device *xe) return err; } -static void xe_display_fini(struct xe_device *__xe, void *arg) +static void xe_display_fini(void *arg) { struct xe_device *xe = arg; struct intel_display *display = &xe->display; @@ -183,7 +183,7 @@ int xe_display_init(struct xe_device *xe) if (err) return err; - return xe_device_add_action_or_reset(xe, xe_display_fini, xe); + return devm_add_action_or_reset(xe->drm.dev, xe_display_fini, xe); } void xe_display_register(struct xe_device *xe) diff --git a/drivers/gpu/drm/xe/xe_gsc_proxy.c b/drivers/gpu/drm/xe/xe_gsc_proxy.c index 6aa76a7843cfa..8cf70b228ff3b 100644 --- a/drivers/gpu/drm/xe/xe_gsc_proxy.c +++ b/drivers/gpu/drm/xe/xe_gsc_proxy.c @@ -423,7 +423,7 @@ static int proxy_channel_alloc(struct xe_gsc *gsc) return 0; } -static void xe_gsc_proxy_remove(struct xe_device *__xe, void *arg) +static void xe_gsc_proxy_remove(void *arg) { struct xe_gsc *gsc = arg; struct xe_gt *gt = gsc_to_gt(gsc); @@ -490,7 +490,7 @@ int xe_gsc_proxy_init(struct xe_gsc *gsc) gsc->proxy.component_added = true; - return xe_device_add_action_or_reset(xe, xe_gsc_proxy_remove, gsc); + return devm_add_action_or_reset(xe->drm.dev, xe_gsc_proxy_remove, gsc); } /** From patchwork Wed Feb 12 20:05:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 13972397 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 62410C02198 for ; Wed, 12 Feb 2025 20:06:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7A8C610E97E; Wed, 12 Feb 2025 20:06:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="IPEinzJc"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0BC8910E97E for ; Wed, 12 Feb 2025 20:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1739390769; x=1770926769; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Gr626Pije9wvykEMTGa0ijTndejJ/ehjVeon9HAk+UU=; b=IPEinzJcFFN2aCUc5ReplUMXvsner+sBnOWKh2SCPsE6HBS20PnJrPSX jCIjfVlua356+xMXDy1mrbbth45W2c5pz6AOEMqp3ae9AnGIn/icEILhq MW0irKONA++q6JrpIViUOfNhoAVzb4eiw5Hz7dN5bWdfBoMG6bAW/GYdj Vc5NdG6/DCyEEX+91yAEeZhpCBdo/6oRpYdvf6MNLFAK6llLQQXK6V6OK TagaKUWB3DxdbuN8S8qehuXKp2yggnJlBXXtujBUcRCGpJSO0Q4MrVed2 TPGGS5NurpHgP0fbvCkYwYgI6iYKEj1lNxJBsEWKRyB6e5lhnXrVmoweO A==; X-CSE-ConnectionGUID: UqSu2pnkTIa3rmW561e8fg== X-CSE-MsgGUID: O03ZSP13Td2IrWcUFPuy+Q== X-IronPort-AV: E=McAfee;i="6700,10204,11343"; a="50718511" X-IronPort-AV: E=Sophos;i="6.13,280,1732608000"; d="scan'208";a="50718511" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 12:06:08 -0800 X-CSE-ConnectionGUID: nO6j/1LaSwKZdrcUYzdffQ== X-CSE-MsgGUID: TCOz3OYYR0y5qL07mSklIw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,280,1732608000"; d="scan'208";a="118010770" Received: from lucas-s2600cw.jf.intel.com ([10.165.21.196]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Feb 2025 12:06:08 -0800 From: Lucas De Marchi To: linux-kernel@vger.kernel.org Cc: Rodrigo Vivi , dri-devel@lists.freedesktop.org, Danilo Krummrich , "Rafael J. Wysocki" , Greg Kroah-Hartman , Lucas De Marchi Subject: [PATCH 6/6] drm/xe: Drop remove callback support Date: Wed, 12 Feb 2025 12:05:42 -0800 Message-ID: <20250212200542.515493-7-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250212200542.515493-1-lucas.demarchi@intel.com> References: <20250212200542.515493-1-lucas.demarchi@intel.com> 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" Now that devres supports component driver cleanup during driver removal cleanup, the xe custom support for removal callbacks is not needed anymore. Drop it. Signed-off-by: Lucas De Marchi --- drivers/gpu/drm/xe/xe_device.c | 79 ---------------------------- drivers/gpu/drm/xe/xe_device.h | 4 -- drivers/gpu/drm/xe/xe_device_types.h | 17 ------ drivers/gpu/drm/xe/xe_pci.c | 4 +- 4 files changed, 1 insertion(+), 103 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c index 4b4039cf29fd4..d83400bbff8b1 100644 --- a/drivers/gpu/drm/xe/xe_device.c +++ b/drivers/gpu/drm/xe/xe_device.c @@ -65,12 +65,6 @@ #include -struct xe_device_remove_action { - struct list_head node; - xe_device_remove_action_t remove; - void *data; -}; - static int xe_file_open(struct drm_device *dev, struct drm_file *file) { struct xe_device *xe = to_xe_device(dev); @@ -752,9 +746,6 @@ int xe_device_probe(struct xe_device *xe) int err; u8 id; - xe->probing = true; - INIT_LIST_HEAD(&xe->remove_action_list); - xe_pat_init_early(xe); err = xe_sriov_init(xe); @@ -904,8 +895,6 @@ int xe_device_probe(struct xe_device *xe) xe_vsec_init(xe); - xe->probing = false; - return devm_add_action_or_reset(xe->drm.dev, xe_device_sanitize, xe); err_unregister_display: @@ -916,72 +905,6 @@ int xe_device_probe(struct xe_device *xe) return err; } -/** - * xe_device_call_remove_actions - Call the remove actions - * @xe: xe device instance - * - * This is only to be used by xe_pci and xe_device to call the remove actions - * while removing the driver or handling probe failures. - */ -void xe_device_call_remove_actions(struct xe_device *xe) -{ - struct xe_device_remove_action *ra, *tmp; - - list_for_each_entry_safe(ra, tmp, &xe->remove_action_list, node) { - ra->remove(xe, ra->data); - list_del(&ra->node); - kfree(ra); - } - - xe->probing = false; -} - -/** - * xe_device_add_action_or_reset - Add an action to run on driver removal - * @xe: xe device instance - * @ra: pointer to the object embedded into the object to cleanup - * @remove: function to execute. The @ra is passed as argument - * - * Example: - * - * .. code-block:: c - * - * static void foo_remove(struct xe_device_remove_action *ra) - * { - * struct xe_foo *foo = container_of(ra, struct xe_foo, remove_action); - * ... - * } - * - * int xe_foo_init(struct xe_foo *foo) - * { - * ... - * xe_device_add_remove_action(xe, &foo->remove_action, foo_remove); - * ... - * return 0; - * }; - */ -int xe_device_add_action_or_reset(struct xe_device *xe, - xe_device_remove_action_t action, - void *data) -{ - struct xe_device_remove_action *ra; - - drm_WARN_ON(&xe->drm, !xe->probing); - - ra = kmalloc(sizeof(*ra), GFP_KERNEL); - if (!ra) { - action(xe, data); - return -ENOMEM; - } - - INIT_LIST_HEAD(&ra->node); - ra->remove = action; - ra->data = data; - list_add(&ra->node, &xe->remove_action_list); - - return 0; -} - void xe_device_remove(struct xe_device *xe) { xe_display_unregister(xe); @@ -991,8 +914,6 @@ void xe_device_remove(struct xe_device *xe) xe_display_driver_remove(xe); xe_heci_gsc_fini(xe); - - xe_device_call_remove_actions(xe); } void xe_device_shutdown(struct xe_device *xe) diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/xe_device.h index a6fedf1ef3c7b..0bc3bc8e68030 100644 --- a/drivers/gpu/drm/xe/xe_device.h +++ b/drivers/gpu/drm/xe/xe_device.h @@ -45,10 +45,6 @@ struct xe_device *xe_device_create(struct pci_dev *pdev, const struct pci_device_id *ent); int xe_device_probe_early(struct xe_device *xe); int xe_device_probe(struct xe_device *xe); -int xe_device_add_action_or_reset(struct xe_device *xe, - xe_device_remove_action_t action, - void *data); -void xe_device_call_remove_actions(struct xe_device *xe); void xe_device_remove(struct xe_device *xe); void xe_device_shutdown(struct xe_device *xe); diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h index b322d49c83c77..833c29fed3a37 100644 --- a/drivers/gpu/drm/xe/xe_device_types.h +++ b/drivers/gpu/drm/xe/xe_device_types.h @@ -35,7 +35,6 @@ #include "intel_display_device.h" #endif -struct xe_device; struct xe_ggtt; struct xe_pat_ops; struct xe_pxp; @@ -71,8 +70,6 @@ struct xe_pxp; const struct xe_tile * : (const struct xe_device *)((tile__)->xe), \ struct xe_tile * : (tile__)->xe) -typedef void (*xe_device_remove_action_t)(struct xe_device *xe, void *data); - /** * struct xe_vram_region - memory region structure * This is used to describe a memory region in xe @@ -431,20 +428,6 @@ struct xe_device { /** @tiles: device tiles */ struct xe_tile tiles[XE_MAX_TILES_PER_DEVICE]; - /** - * @remove_action_list: list of actions to execute on device remove. - * Use xe_device_add_remove_action() for that. Actions can only be added - * during probe and are executed during the call from PCI subsystem to - * remove the driver from the device. - */ - struct list_head remove_action_list; - - /** - * @probing: cover the section in which @remove_action_list can be used - * to post cleaning actions - */ - bool probing; - /** * @mem_access: keep track of memory access in the device, possibly * triggering additional actions when they occur. diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c index 41ec6825b9bcc..447eacb355d7c 100644 --- a/drivers/gpu/drm/xe/xe_pci.c +++ b/drivers/gpu/drm/xe/xe_pci.c @@ -900,10 +900,8 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return err; err = xe_device_probe(xe); - if (err) { - xe_device_call_remove_actions(xe); + if (err) return err; - } err = xe_pm_init(xe); if (err)