From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AA73C433E0 for ; Tue, 9 Jun 2020 17:53:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DDB2E20774 for ; Tue, 9 Jun 2020 17:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591725208; bh=QY93wMTMJtChRvyaGZk2P4YKUxEb/t/zQgecsPwdtVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Byqub6PZhSo3isoGjEt0T47OlA57V9UENIvEGEPWEQUqOiPDZNapimh7AIc/qSI3/ wZxi0IkXh/CeBUc94Sek7doD9lcFObdmN7mHF60LRKNinEJPxC1tICuoUM092WTgPF U+J3BKaeSLh3hKNqObhhxaiuW6/SMbvCZmVlV1GE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733030AbgFIRxZ (ORCPT ); Tue, 9 Jun 2020 13:53:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:42582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729795AbgFIRwV (ORCPT ); Tue, 9 Jun 2020 13:52:21 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4088F2074B; Tue, 9 Jun 2020 17:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591725140; bh=QY93wMTMJtChRvyaGZk2P4YKUxEb/t/zQgecsPwdtVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zHYVNCexZ/kBweTH01TDlTOtDRSj3/mYWv2jsfVslW7SQg1D0JyZGFjnq51kpJL6j rhnwhYAaHtlbaiFqCVJ+g2E6KSmGGYCJdQkf7+RiCwebaPM0UUhEXtRQTL0PKmKZR9 qhBbns4A9Nm36vh6QgvstoF0AOhpHH4I8KvrSwec= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dexuan Cui , Mark Bloch , Moshe Shemesh , Saeed Mahameed Subject: [PATCH 5.4 04/34] net/mlx5: Fix crash upon suspend/resume Date: Tue, 9 Jun 2020 19:45:00 +0200 Message-Id: <20200609174053.194915880@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200609174052.628006868@linuxfoundation.org> References: <20200609174052.628006868@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Bloch [ Upstream commit 8fc3e29be9248048f449793502c15af329f35c6e ] Currently a Linux system with the mlx5 NIC always crashes upon hibernation - suspend/resume. Add basic callbacks so the NIC could be suspended and resumed. Fixes: 9603b61de1ee ("mlx5: Move pci device handling from mlx5_ib to mlx5_core") Tested-by: Dexuan Cui Signed-off-by: Mark Bloch Reviewed-by: Moshe Shemesh Signed-off-by: Saeed Mahameed Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlx5/core/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -1554,6 +1554,22 @@ static void shutdown(struct pci_dev *pde mlx5_pci_disable_device(dev); } +static int mlx5_suspend(struct pci_dev *pdev, pm_message_t state) +{ + struct mlx5_core_dev *dev = pci_get_drvdata(pdev); + + mlx5_unload_one(dev, false); + + return 0; +} + +static int mlx5_resume(struct pci_dev *pdev) +{ + struct mlx5_core_dev *dev = pci_get_drvdata(pdev); + + return mlx5_load_one(dev, false); +} + static const struct pci_device_id mlx5_core_pci_table[] = { { PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_CONNECTIB) }, { PCI_VDEVICE(MELLANOX, 0x1012), MLX5_PCI_DEV_IS_VF}, /* Connect-IB VF */ @@ -1597,6 +1613,8 @@ static struct pci_driver mlx5_core_drive .id_table = mlx5_core_pci_table, .probe = init_one, .remove = remove_one, + .suspend = mlx5_suspend, + .resume = mlx5_resume, .shutdown = shutdown, .err_handler = &mlx5_err_handler, .sriov_configure = mlx5_core_sriov_configure,