From patchwork Thu Sep 28 09:19:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 13402384 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 C9811CE7B0F for ; Thu, 28 Sep 2023 09:20:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D61A310E095; Thu, 28 Sep 2023 09:20:12 +0000 (UTC) Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B51110E095 for ; Thu, 28 Sep 2023 09:20:06 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 93166CE1C66; Thu, 28 Sep 2023 09:20:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3DB0C433C8; Thu, 28 Sep 2023 09:20:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695892801; bh=9e29ZnhPKlU/RRKb54lBCqFLUcPtDveR1H2fkbEg0Mw=; h=From:To:Cc:Subject:Date:From; b=sxZosAONQP0lCPkBzlF1Si/T9gAVuSwvT2UYa38Fr4lHYbVjJMOBuN42Xnqcb2Zid 23LGgKhjtUoqQR/9vWtPpCdnOicoNQSC/VfEe9s4BLtow8WcrPtbOD129Y1xgENvuw WNpdabr3e1tz5Xxb1j4m9Fwyx1wRr81EOBQpmyasDe4m8LBov2r19m1lZWInqqRSw+ PKtq7XBjf0i3syZQ9PysfLeFP+QArk+Trdgg02++goSRXbKSXWSDMq8JeaAUM3juWD p9LxjVJzxMPNyvj2Nww2lkeYMd0j7N1hfKkH2WPcGzLfB+RvR7ODzjCGRWVIf75Z0h YDSWEE6sXZKOQ== From: Oded Gabbay To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] accel/habanalabs: remove wrong doc for init_phys_pg_pack_from_userptr Date: Thu, 28 Sep 2023 12:19:54 +0300 Message-Id: <20230928091956.47762-1-ogabbay@kernel.org> X-Mailer: git-send-email 2.34.1 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: Dafna Hirschfeld Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dafna Hirschfeld The function does not pin the pages so remove that from the inline doc. Signed-off-by: Dafna Hirschfeld Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay --- drivers/accel/habanalabs/common/memory.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/accel/habanalabs/common/memory.c b/drivers/accel/habanalabs/common/memory.c index ba59e921236e..0b8689fe0b64 100644 --- a/drivers/accel/habanalabs/common/memory.c +++ b/drivers/accel/habanalabs/common/memory.c @@ -832,7 +832,6 @@ int hl_unreserve_va_block(struct hl_device *hdev, struct hl_ctx *ctx, * physical pages * * This function does the following: - * - Pin the physical pages related to the given virtual block. * - Create a physical page pack from the physical pages related to the given * virtual block. */ From patchwork Thu Sep 28 09:19:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 13402382 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 60E02CE7B11 for ; Thu, 28 Sep 2023 09:20:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E631010E0A3; Thu, 28 Sep 2023 09:20:07 +0000 (UTC) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6EF2A10E095 for ; Thu, 28 Sep 2023 09:20:05 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 25FD3B81B73; Thu, 28 Sep 2023 09:20:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63BC0C433C9; Thu, 28 Sep 2023 09:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695892803; bh=Vyr3UyZZ56ptALGkLm5eY95Jkj8E0OURUt5Ep5UjUSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fWvw/wPiff/w5nZ05hgT3Q5bBjC92yz+6Tn8DSykvtTgZ1x7o/N9qDR6pezkqCnVy 7mcUOaGNqemrx5WMZkRtV7KU+jz3+qBZlF3eZWJsgrA3sbX9n/1/ZIetV8lF1j8sga 3sXmBdjrzopQ3NLEllo5CDvoYCETqSpjy1XYqUQLbi4uNt8A/mXDP7M22Wk/6HvDC2 o+nbirwXjZ0PdHTfO4NZBy44ZRJ6Ja/TZdA0/nT6ns+7004DLHZmUlPppKc6AkEK4+ JxAVgwTI4OXZ797dcURyFyLsHVFbIOE7Z5DNzQFhHC2hL2OP2AiQfHZjkeji7jB6hF BlQH1Leh1yU7g== From: Oded Gabbay To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] accel/habanalabs: fix bug in decoder wait for cs completion Date: Thu, 28 Sep 2023 12:19:55 +0300 Message-Id: <20230928091956.47762-2-ogabbay@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928091956.47762-1-ogabbay@kernel.org> References: <20230928091956.47762-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: farah kassabri Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: farah kassabri The decoder interrupts are handled in the interrupt context same as all user interrupts. In such case, the wait list should be protected by spin_lock_irqsave in order to avoid deadlock that might happen with the user submission flow. Signed-off-by: farah kassabri Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay --- .../accel/habanalabs/common/command_submission.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/accel/habanalabs/common/command_submission.c b/drivers/accel/habanalabs/common/command_submission.c index 4f7b70d9754c..3aa6eeef443b 100644 --- a/drivers/accel/habanalabs/common/command_submission.c +++ b/drivers/accel/habanalabs/common/command_submission.c @@ -3526,7 +3526,7 @@ static int _hl_interrupt_wait_ioctl_user_addr(struct hl_device *hdev, struct hl_ u64 *timestamp) { struct hl_user_pending_interrupt *pend; - unsigned long timeout; + unsigned long timeout, flags; u64 completion_value; long completion_rc; int rc = 0; @@ -3546,9 +3546,9 @@ static int _hl_interrupt_wait_ioctl_user_addr(struct hl_device *hdev, struct hl_ /* Add pending user interrupt to relevant list for the interrupt * handler to monitor */ - spin_lock(&interrupt->wait_list_lock); + spin_lock_irqsave(&interrupt->wait_list_lock, flags); list_add_tail(&pend->list_node, &interrupt->wait_list_head); - spin_unlock(&interrupt->wait_list_lock); + spin_unlock_irqrestore(&interrupt->wait_list_lock, flags); /* We check for completion value as interrupt could have been received * before we added the node to the wait list @@ -3579,14 +3579,14 @@ static int _hl_interrupt_wait_ioctl_user_addr(struct hl_device *hdev, struct hl_ * If comparison fails, keep waiting until timeout expires */ if (completion_rc > 0) { - spin_lock(&interrupt->wait_list_lock); + spin_lock_irqsave(&interrupt->wait_list_lock, flags); /* reinit_completion must be called before we check for user * completion value, otherwise, if interrupt is received after * the comparison and before the next wait_for_completion, * we will reach timeout and fail */ reinit_completion(&pend->fence.completion); - spin_unlock(&interrupt->wait_list_lock); + spin_unlock_irqrestore(&interrupt->wait_list_lock, flags); if (copy_from_user(&completion_value, u64_to_user_ptr(user_address), 8)) { dev_err(hdev->dev, "Failed to copy completion value from user\n"); @@ -3623,9 +3623,9 @@ static int _hl_interrupt_wait_ioctl_user_addr(struct hl_device *hdev, struct hl_ } remove_pending_user_interrupt: - spin_lock(&interrupt->wait_list_lock); + spin_lock_irqsave(&interrupt->wait_list_lock, flags); list_del(&pend->list_node); - spin_unlock(&interrupt->wait_list_lock); + spin_unlock_irqrestore(&interrupt->wait_list_lock, flags); *timestamp = ktime_to_ns(pend->fence.timestamp); From patchwork Thu Sep 28 09:19:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 13402383 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 0C42ECE7B11 for ; Thu, 28 Sep 2023 09:20:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B42A210E0AA; Thu, 28 Sep 2023 09:20:11 +0000 (UTC) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id 918A510E095 for ; Thu, 28 Sep 2023 09:20:07 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id C90C4B81B7E; Thu, 28 Sep 2023 09:20:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1222DC433C7; Thu, 28 Sep 2023 09:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695892805; bh=BMuxTiku+IlvNWwdHgMDtNzm/glYc+SS1e8AMX4mWDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DcQuR0gUyWlSbivUkssE/B80V9GssI/Sv70+YozuQ8mwVjvvCppHi6w79RQGWwM0A AXrNFtz6WHErXiRxjmbS+BQomkhMwtD2/nhCPai/v0RdA7qvXrmb7lSGSIJ+bnW7tV 8pblNnvZfW6PVrPPTSmp2phezQQges2ydSBKEzuGMjMoiBm3JFojfdKj7a57M6ewy2 PFm33xdcHFLvd1P/WVYknIwavX2OjMngsTN5Bb/Di45039mGZW0IPE275scvjABXVj IzQMnpIx2IvUpCbGPUgaTZPGbDsUDDoHdCnBFC8X8UuCE1UB/itxbXPGAQAmPFzzZO 4Cyl1INTMbrHw== From: Oded Gabbay To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] accel/habanalabs/gaudi2: perform hard-reset upon PCIe AXI drain event Date: Thu, 28 Sep 2023 12:19:56 +0300 Message-Id: <20230928091956.47762-3-ogabbay@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928091956.47762-1-ogabbay@kernel.org> References: <20230928091956.47762-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: Tomer Tayar Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomer Tayar Non-completed transactions from PCIe towards the device are handled by the AXI drain mechanism. This handling is in the PCIe level, but the transactions are still there in the device consuming some queues entries, and therefore the device must be reset. Modify to perform hard-reset upon PCIe AXI drain events. Signed-off-by: Tomer Tayar Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay --- .../habanalabs/include/gaudi2/gaudi2_async_ids_map_extended.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/accel/habanalabs/include/gaudi2/gaudi2_async_ids_map_extended.h b/drivers/accel/habanalabs/include/gaudi2/gaudi2_async_ids_map_extended.h index 57e661771b6c..b2dbe1f64430 100644 --- a/drivers/accel/habanalabs/include/gaudi2/gaudi2_async_ids_map_extended.h +++ b/drivers/accel/habanalabs/include/gaudi2/gaudi2_async_ids_map_extended.h @@ -1293,7 +1293,7 @@ static struct gaudi2_async_events_ids_map gaudi2_irq_map_table[] = { .name = "" }, { .fc_id = 631, .cpu_id = 128, .valid = 1, .msg = 0, .reset = EVENT_RESET_TYPE_NONE, .name = "PCIE_P2P_MSIX" }, - { .fc_id = 632, .cpu_id = 129, .valid = 1, .msg = 0, .reset = EVENT_RESET_TYPE_NONE, + { .fc_id = 632, .cpu_id = 129, .valid = 1, .msg = 0, .reset = EVENT_RESET_TYPE_HARD, .name = "PCIE_DRAIN_COMPLETE" }, { .fc_id = 633, .cpu_id = 130, .valid = 1, .msg = 0, .reset = EVENT_RESET_TYPE_NONE, .name = "TPC0_BMON_SPMU" },