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=unavailable 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 B0D74C433DF for ; Tue, 9 Jun 2020 17:58:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86D5B206D5 for ; Tue, 9 Jun 2020 17:58:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591725513; bh=eEi2BJJpFfnkUtBswv1aNYBxmzGniwh10zqbzAln51k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Pqtr0HgXxILoNucRmEVHocXhwEcXc+LXhKOeKE+25X05H6TAnl+kIC8nwsIATAsuf wAaSKxJh7cQPZRLZKTrQK6QxfCA+dgAAbidQRIPsSyS6ucL3Q9a+N+N6CdYbcS3bRr TbLGLNBvZuQ76E1vp4qW+kzf71mpDxYBshktTjJI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733232AbgFIRzU (ORCPT ); Tue, 9 Jun 2020 13:55:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:44566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726100AbgFIRxa (ORCPT ); Tue, 9 Jun 2020 13:53:30 -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 B01F020774; Tue, 9 Jun 2020 17:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591725210; bh=eEi2BJJpFfnkUtBswv1aNYBxmzGniwh10zqbzAln51k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z6eKE9ZWHphkC+FX4qn26Jivqs1pQ8DtnGTRSs1eMdEHxmE8lxVlNor+giovZDaBj 2IzNv8VkpPNmq+h68XYbp334cuj+Q8ZjDkfclxT8WI5zgK9IoTtksYsKXJeDhAw62H ZPuBS8/gtSbnSt0bwd71oU45aC0pFDFTb2HWlYDY= 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.6 05/41] net/mlx5: Fix crash upon suspend/resume Date: Tue, 9 Jun 2020 19:45:07 +0200 Message-Id: <20200609174112.638366127@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200609174112.129412236@linuxfoundation.org> References: <20200609174112.129412236@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 @@ -1552,6 +1552,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 */ @@ -1595,6 +1611,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,