Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3323274rwa; Tue, 23 Aug 2022 02:50:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR4PHv8sMFtD5bjh2zvksRcx1TwUKov2itohcjkWOEDS8jVNa8Ng3xidh8dDyyQDiRqeSQkW X-Received: by 2002:a63:81c8:0:b0:429:ead2:6dc2 with SMTP id t191-20020a6381c8000000b00429ead26dc2mr20271563pgd.395.1661248224029; Tue, 23 Aug 2022 02:50:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248224; cv=none; d=google.com; s=arc-20160816; b=R0WNdXZv3T/NlD9crMSTfV9WsCpNbPfN9yooAQ6Y2q8KZXqYiWMDEDNTVJMboOIE+X 4dpRGq5IgNqQVWmZvbM+in8x4r8DPO3TDImaAbdDtLwA3LlItYS3+dSQHh3IXVujvmHs 2hAGjjDh6zXM874HyJEDN4FI9BNtL/GdtW6GvCJgug1kxkbOERCoZcbeoFAxHoS31wT1 dp+TzzQMJBdHhZw7jzCWcVwnOVI5Htmq6v3OLjwIdhu4bh273bkVsib2tlMF9kDg9pJz mfF2BdLvKA9WIzqlqb6CC1rq4/d8CbdI95uObNsudJ98DXdxogNBCXD5u18cfK3seGUo UuUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=phf8YWhjGWTf9pP1cHWc24t9YZxyT1KCTWGkCGnSl10=; b=LLIzE4AkM/D3XHH3HJl3bAVIYFcb6Fnqg1hf1gP1+fkH54aQKNUGDUMQ+MTvtIvR5O uE05bww3TX6m9YJ+b25obRfdFyiD0iP4bS1H9CI0MfzsjoVzHMGF2oGWShEvb5I1wPpr OVqcA7rBq9ZllY0cJNciAbhb8qmvTuYvxSWxjbC/2cEh33NdJsnMv+7PgnU+WP7NWbSv ICTr0MQ6XGvZhBDpYPRMS27BSjcouOHd+CSNzbbu+Ld4TGNZbdOPMY3upqNbx+O6fNoV U+NF2pFpOAXD8wmTsH8znfDVwhWx5MghJUIwwEibs0zi0RopCG0XRA1YmULed/jLQt+V o/Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wj33+jL0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c25-20020aa78e19000000b0052dfe17ce46si14259968pfr.285.2022.08.23.02.50.13; Tue, 23 Aug 2022 02:50:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wj33+jL0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243239AbiHWJOJ (ORCPT + 99 others); Tue, 23 Aug 2022 05:14:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348981AbiHWJLE (ORCPT ); Tue, 23 Aug 2022 05:11:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04B8786B7B; Tue, 23 Aug 2022 01:31:16 -0700 (PDT) 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 8F9016148F; Tue, 23 Aug 2022 08:31:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BB6EC433D7; Tue, 23 Aug 2022 08:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243476; bh=sKiCDr2+rFLbZVPMxLPNCZjeW042ncbG+hqCMa4nj3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wj33+jL0xrhAf4H/BqeKmElZ9E+3N/Uy9V2DPl4v0bBkvo0dqMe00oK2qEf1vazOP lnuWF+bL1Vzf+XNveyAhFDQkXXmiOhgenu5HrltWEmBILd4fuHYJbL4JxGh4Yxu3Kn h83Po7ZBKtnWxQ7j9y32KdVB0FJ+JIjAIbUpr4Lk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tal Cohen , Oded Gabbay , Sasha Levin Subject: [PATCH 5.19 289/365] habanalabs/gaudi: invoke device reset from one code block Date: Tue, 23 Aug 2022 10:03:10 +0200 Message-Id: <20220823080130.294328482@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tal Cohen [ Upstream commit be572e67dafbf8004d46a2c9d97338c107efb60e ] In order to prepare the driver code for device reset event notification, change the event handler function flow to call device reset from one code block. In addition, the commit fixes an issue that reset was performed w/o checking the 'hard_reset_on_fw_event' state and w/o setting the HL_DRV_RESET_DELAY flag. Signed-off-by: Tal Cohen Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin --- drivers/misc/habanalabs/gaudi/gaudi.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c index 25d735aee6a3..e6bfaf55c6b6 100644 --- a/drivers/misc/habanalabs/gaudi/gaudi.c +++ b/drivers/misc/habanalabs/gaudi/gaudi.c @@ -7717,10 +7717,10 @@ static void gaudi_handle_eqe(struct hl_device *hdev, struct gaudi_device *gaudi = hdev->asic_specific; u64 data = le64_to_cpu(eq_entry->data[0]); u32 ctl = le32_to_cpu(eq_entry->hdr.ctl); - u32 fw_fatal_err_flag = 0; + u32 fw_fatal_err_flag = 0, flags = 0; u16 event_type = ((ctl & EQ_CTL_EVENT_TYPE_MASK) >> EQ_CTL_EVENT_TYPE_SHIFT); - bool reset_required; + bool reset_required, reset_direct = false; u8 cause; int rc; @@ -7808,7 +7808,8 @@ static void gaudi_handle_eqe(struct hl_device *hdev, dev_err(hdev->dev, "reset required due to %s\n", gaudi_irq_map_table[event_type].name); - hl_device_reset(hdev, 0); + reset_direct = true; + goto reset_device; } else { hl_fw_unmask_irq(hdev, event_type); } @@ -7830,7 +7831,8 @@ static void gaudi_handle_eqe(struct hl_device *hdev, dev_err(hdev->dev, "reset required due to %s\n", gaudi_irq_map_table[event_type].name); - hl_device_reset(hdev, 0); + reset_direct = true; + goto reset_device; } else { hl_fw_unmask_irq(hdev, event_type); } @@ -7981,12 +7983,17 @@ static void gaudi_handle_eqe(struct hl_device *hdev, return; reset_device: - if (hdev->asic_prop.fw_security_enabled) - hl_device_reset(hdev, HL_DRV_RESET_HARD - | HL_DRV_RESET_BYPASS_REQ_TO_FW - | fw_fatal_err_flag); + reset_required = true; + + if (hdev->asic_prop.fw_security_enabled && !reset_direct) + flags = HL_DRV_RESET_HARD | HL_DRV_RESET_BYPASS_REQ_TO_FW | fw_fatal_err_flag; else if (hdev->hard_reset_on_fw_events) - hl_device_reset(hdev, HL_DRV_RESET_HARD | HL_DRV_RESET_DELAY | fw_fatal_err_flag); + flags = HL_DRV_RESET_HARD | HL_DRV_RESET_DELAY | fw_fatal_err_flag; + else + reset_required = false; + + if (reset_required) + hl_device_reset(hdev, flags); else hl_fw_unmask_irq(hdev, event_type); } -- 2.35.1