From patchwork Tue Jun 2 02:08:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1302030 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49bb836GCDz9sSn; Tue, 2 Jun 2020 12:09:23 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jfwMg-0005t3-Oq; Tue, 02 Jun 2020 02:09:18 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jfwMU-0005g6-1d for kernel-team@lists.ubuntu.com; Tue, 02 Jun 2020 02:09:06 +0000 Received: from mail-qv1-f69.google.com ([209.85.219.69]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jfwMS-00022M-2s for kernel-team@lists.ubuntu.com; Tue, 02 Jun 2020 02:09:04 +0000 Received: by mail-qv1-f69.google.com with SMTP id i6so2056260qvq.17 for ; Mon, 01 Jun 2020 19:09:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NJRuraGrzp80qkod3Glqbj4dDmShPpDhrC3S90kZPyk=; b=uaCj1v/lp9yCvV4SyFYeB4tzI1B7JgzOO8HZs9W7+eptqhKbk20gLaZ/in4md74FsV SY9LsHajWA/PmNf5nppL40nz77zqP1wG+Cagm8cytFfQfZhJ2gxV6FOfISthqUyTDNUt vSk07SDaGnHXC5Fz4IIuQOT95ElzQhR4Gu6GLJRdeyaSIagjVQAwkq3qfb7ZwfwbGnVn lWxb+hRVNrhECfNbzzLTn2dtnQ01jMiFsGFFkC0pibmqh89uF+xhTPfF2xSW+3fjadYQ VB8ZFJWKdNQGyiqcFoMTELedc4IGh8jZAncF+/Ecmj6lQaqpzThp5IhxhbNCQXmOivGv 65ig== X-Gm-Message-State: AOAM533Lij8XRJmxKg4eQC4RIVPA8dM12meKqOjXB1WjiENIlbYCHuTW tmwf2usOBMKe5GBEXbnHFeFEDP7cBSDfMjQFQOCb75qlseFHrOTXDl9R/Qa3g25tZzBMS1qW5T6 fXM0iKkFHtlv/utrX4gadpQ5uO4UrUpklULqZWkXe X-Received: by 2002:a0c:aa4c:: with SMTP id e12mr22987093qvb.12.1591063742691; Mon, 01 Jun 2020 19:09:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQcTfbDvzoxei3nsOSCjPacc5FD+oTVuxyM/7FvQOVibXJlHgGoAGWb9THkzfh8tv9kXNt1A== X-Received: by 2002:a0c:aa4c:: with SMTP id e12mr22987078qvb.12.1591063742374; Mon, 01 Jun 2020 19:09:02 -0700 (PDT) Received: from gallifrey.lan ([201.82.186.200]) by smtp.gmail.com with ESMTPSA id t13sm1138342qtc.77.2020.06.01.19.09.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jun 2020 19:09:01 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [focal:linux-azure][PATCH 21/21] net/mlx5: Fix crash upon suspend/resume Date: Mon, 1 Jun 2020 23:08:17 -0300 Message-Id: <20200602020817.236422-22-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200602020817.236422-1-marcelo.cerri@canonical.com> References: <20200602020817.236422-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Mark Bloch BugLink: http://bugs.launchpad.net/bugs/1880032 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 (cherry picked from commit 8fc3e29be9248048f449793502c15af329f35c6e) Signed-off-by: Marcelo Henrique Cerri --- drivers/net/ethernet/mellanox/mlx5/core/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index c96a0e501007..297b5dc64a25 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c @@ -1553,6 +1553,22 @@ static void shutdown(struct pci_dev *pdev) 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 */ @@ -1596,6 +1612,8 @@ static struct pci_driver mlx5_core_driver = { .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,