From patchwork Thu Jun 8 13:38:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 13272352 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 24879C7EE23 for ; Thu, 8 Jun 2023 13:39:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3702410E5C3; Thu, 8 Jun 2023 13:39:13 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B75210E5C3 for ; Thu, 8 Jun 2023 13:39:11 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 990E364DA5; Thu, 8 Jun 2023 13:39:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD758C433A4; Thu, 8 Jun 2023 13:39:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686231549; bh=Zpq/Y9o+eInggKNe8WO7TUg/6TozBHClv8sQmA9lFIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RO8bTPCVN5s7yQf4Il5GoOb2rNzQyuZKpKA9lzvj1W7fIxAKBo3GbJYrrIMOdpyOF CUA/barHBnEDNx77TeW4jp1biYmXZ3mEF0jdjpUMe9kn+vLrrP1ENSuH7GVSB5HJQB lB3BE46GhbibX73kM4nouKd6y1wwYYflnwa795fPPvMRz9vLWpCfxlk6TSbcd7/34/ NtQHYbpSYoywR01t8aYwJkLLbopv6DRTfVm4prhSjqqfe8/0x3ecS/Pp/3vEx2nWjN CbjfzJ5QMLpmivCQM1brS3fKt2j76rJwfmGsIpB3TjJlbLHk4uUZwL8Qr6zNOZUkst ZYqI3mkjOv6Kw== From: Oded Gabbay To: dri-devel@lists.freedesktop.org Subject: [PATCH 11/12] accel/habanalabs: call put_pid after hpriv list is updated Date: Thu, 8 Jun 2023 16:38:48 +0300 Message-Id: <20230608133849.2739411-11-ogabbay@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230608133849.2739411-1-ogabbay@kernel.org> References: <20230608133849.2739411-1-ogabbay@kernel.org> 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: , Cc: Koby Elbaz Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Koby Elbaz Because we might still be using related resources, decrementing PID's reference count should be done at later stages of the device release. A good place is right after the representing private structure is removed from LKD's list. Signed-off-by: Koby Elbaz Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay --- drivers/accel/habanalabs/common/device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/accel/habanalabs/common/device.c b/drivers/accel/habanalabs/common/device.c index 764d40c0d666..c61a58a2e622 100644 --- a/drivers/accel/habanalabs/common/device.c +++ b/drivers/accel/habanalabs/common/device.c @@ -408,8 +408,6 @@ static void hpriv_release(struct kref *ref) hdev->asic_funcs->send_device_activity(hdev, false); - put_pid(hpriv->taskpid); - hl_debugfs_remove_file(hpriv); mutex_destroy(&hpriv->ctx_lock); @@ -448,6 +446,8 @@ static void hpriv_release(struct kref *ref) list_del(&hpriv->dev_node); mutex_unlock(&hdev->fpriv_list_lock); + put_pid(hpriv->taskpid); + if (reset_device) { hl_device_reset(hdev, HL_DRV_RESET_DEV_RELEASE); } else {