From patchwork Tue Apr 18 09:39:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 13215335 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 53050C77B71 for ; Tue, 18 Apr 2023 09:39:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 74B6710E727; Tue, 18 Apr 2023 09:39:58 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id F114A10E723 for ; Tue, 18 Apr 2023 09:39:30 +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 79E9562EE2; Tue, 18 Apr 2023 09:39:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08649C433D2; Tue, 18 Apr 2023 09:39:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681810769; bh=PUiHiQI3VT7vjg61fsTlhga3kjv/W10ivkPyrIDs4Rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eR5vEhEuRjLmXP+dmhRQ0zuHUxQZnGkF5e9sfVhYFroAQyAAetMWbmHPGddrBBoci jg1LyjZTv+0KlVKfD5LH/xfWW768K7c5ZibM0Jy2BPpMJ6HUG8kYKB/WtnGHDksZ4N ed1qurK4/4Sq3PQPxrlFyzmJIBfAGUc0XLfNpbxm63wmZxeHCC06Zy8Ae6/5X4bK2a Mes6+3PkEmFaJJcukHt6exMz5bV6bUdqse1Jn5ndlIyLxTXqpbtKGLrvb1QI2eEwWt k8MO3o3Pp4eFP0BVB5zgbq2l6schWn0kYrmCrOT1WK/oDH7YdoqjHblTmV41Vf6uYY QTXBx4SnhbQ5Q== From: Oded Gabbay To: dri-devel@lists.freedesktop.org Subject: [PATCH 07/10] accel/habanalabs: call to HW/FW err returns 0 when no events exist Date: Tue, 18 Apr 2023 12:39:13 +0300 Message-Id: <20230418093916.2979728-7-ogabbay@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230418093916.2979728-1-ogabbay@kernel.org> References: <20230418093916.2979728-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: Moti Haimovski Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Moti Haimovski This commit modifies the call to retrieve HW or FW error events to return success when no events are pending, as done in the calls to other events. Signed-off-by: Moti Haimovski Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay --- .../habanalabs/common/habanalabs_ioctl.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/accel/habanalabs/common/habanalabs_ioctl.c b/drivers/accel/habanalabs/common/habanalabs_ioctl.c index 203ee857810c..4368e6c9a23a 100644 --- a/drivers/accel/habanalabs/common/habanalabs_ioctl.c +++ b/drivers/accel/habanalabs/common/habanalabs_ioctl.c @@ -842,15 +842,15 @@ static int hw_err_info(struct hl_fpriv *hpriv, struct hl_info_args *args) struct hw_err_info *info; int rc; - if ((!user_buf_size) || (!user_buf)) + if (!user_buf) return -EINVAL; - if (user_buf_size < sizeof(struct hl_info_hw_err_event)) - return -ENOMEM; - info = &hdev->captured_err_info.hw_err; if (!info->event_info_available) - return -ENOENT; + return 0; + + if (user_buf_size < sizeof(struct hl_info_hw_err_event)) + return -ENOMEM; rc = copy_to_user(user_buf, &info->event, sizeof(struct hl_info_hw_err_event)); return rc ? -EFAULT : 0; @@ -864,15 +864,15 @@ static int fw_err_info(struct hl_fpriv *hpriv, struct hl_info_args *args) struct fw_err_info *info; int rc; - if ((!user_buf_size) || (!user_buf)) + if (!user_buf) return -EINVAL; - if (user_buf_size < sizeof(struct hl_info_fw_err_event)) - return -ENOMEM; - info = &hdev->captured_err_info.fw_err; if (!info->event_info_available) - return -ENOENT; + return 0; + + if (user_buf_size < sizeof(struct hl_info_fw_err_event)) + return -ENOMEM; rc = copy_to_user(user_buf, &info->event, sizeof(struct hl_info_fw_err_event)); return rc ? -EFAULT : 0;