Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3930804imm; Mon, 8 Oct 2018 11:53:05 -0700 (PDT) X-Google-Smtp-Source: ACcGV61OJN2vBxtPh6GFEzuhh8t5Th5F/1ime52QWkpOuR6EWWBGBCv5kRETT/OUAHLwAv0I7l6P X-Received: by 2002:a62:215b:: with SMTP id h88-v6mr26185999pfh.233.1539024785862; Mon, 08 Oct 2018 11:53:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024785; cv=none; d=google.com; s=arc-20160816; b=rdW/wOv+l2uKgcxvEnvnJ+tkLP7a41RNP5pxydu+/6M+scRu8dddzY1VaZjHqqVb9E 0mQ5GGTWGvF3cHA9d07CU1lkPGytLQ3SMCRdVnE6IMvnLmPjZMNHkWZd+I6y24F/TnfL 281qc7HoRMyxv+BqRrc0azbBtZN14DwmoeodCTWhw4oWW/ZhF/IIQM+C+8D1PQTyRuQ0 vC9ZrYw5GTadbMaUc2qEfFy5XuDy2Qme4bajRN9KJ5EPXW9kGptVSSBr8jbAlVvx8Tu2 194ZIaKJEqfNlILla42tOulIpO2n/8ctxtT/eP8Y7pMEMPfOmDH3ltnsKV3cKIi24Nu5 Clsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=T06XGX4g3Da/FLYHiTCmQ4K6tvPXkKxxoo/CrdN6p94=; b=J+Rq0cwLBTUGOHqAjY9KS59QzEgV5vUsFpLuFkB66TVgztsRfGg1Ql/12R8+1kjIFR sSAeDqOTPpY2oq6E0gyvXS/CIQDdnxuK1aF56bUdk6LI+E8l2gUuvfEa70BK+zvWTkuJ V5SXuXN1ii95E7QwAVlGc4+o/ak5bORmuz5yuZe2nGFZKPurZbko2dB/Kb6/+3qSrFtu 1lAcvgvHcyh0HX7ZqKE76YCo7dOxPnf1uXPkMzl9mSilBW0LSL24KEVBH94pJWUcsZCA QudmbVrYQ7Bsv/FYIJL1uwdugcYqNmNPMewnOn0bGVYfI4dTzv8cbsWKftNyWFxBuniO QS2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kupg6GZn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 16-v6si23937960pfc.21.2018.10.08.11.52.50; Mon, 08 Oct 2018 11:53:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kupg6GZn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732573AbeJICFq (ORCPT + 99 others); Mon, 8 Oct 2018 22:05:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:55928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727260AbeJICFq (ORCPT ); Mon, 8 Oct 2018 22:05:46 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 1BF882087D; Mon, 8 Oct 2018 18:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024757; bh=c1wlZTfoNRnEt3nR27LKvunfBsTwCanAmgICEJHnww0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kupg6GZnH9c4gHb2uxK8r1tS950VdFlbrPed59QXpKt2EryIUnL1bVngPjALnRVRv JAQIbyN9fFEDuNjLDMmP6D0gxQPmM8zvvboSymF9OhvH7AYxdTkayS8wqrbp+VsAOd 3qtgKHZUSth6XNV3hmoF4Qhvrv6Cy4tMjhPzbotw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Netanel Belgazal , "David S. Miller" , Sasha Levin Subject: [PATCH 4.18 120/168] net: ena: fix device destruction to gracefully free resources Date: Mon, 8 Oct 2018 20:31:40 +0200 Message-Id: <20181008175624.610278349@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Netanel Belgazal [ Upstream commit cfa324a514233b28a6934de619183eee941f02d7 ] When ena_destroy_device() is called from ena_suspend(), the device is still reachable from the driver. Therefore, the driver can send a command to the device to free all resources. However, in all other cases of calling ena_destroy_device(), the device is potentially in an error state and unreachable from the driver. In these cases the driver must not send commands to the device. The current implementation does not request resource freeing from the device even when possible. We add the graceful parameter to ena_destroy_device() to enable resource freeing when possible, and use it in ena_suspend(). Signed-off-by: Netanel Belgazal Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/amazon/ena/ena_netdev.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -76,7 +76,7 @@ MODULE_DEVICE_TABLE(pci, ena_pci_tbl); static int ena_rss_init_default(struct ena_adapter *adapter); static void check_for_admin_com_state(struct ena_adapter *adapter); -static void ena_destroy_device(struct ena_adapter *adapter); +static void ena_destroy_device(struct ena_adapter *adapter, bool graceful); static int ena_restore_device(struct ena_adapter *adapter); static void ena_tx_timeout(struct net_device *dev) @@ -1900,7 +1900,7 @@ static int ena_close(struct net_device * "Destroy failure, restarting device\n"); ena_dump_stats_to_dmesg(adapter); /* rtnl lock already obtained in dev_ioctl() layer */ - ena_destroy_device(adapter); + ena_destroy_device(adapter, false); ena_restore_device(adapter); } @@ -2549,7 +2549,7 @@ err_disable_msix: return rc; } -static void ena_destroy_device(struct ena_adapter *adapter) +static void ena_destroy_device(struct ena_adapter *adapter, bool graceful) { struct net_device *netdev = adapter->netdev; struct ena_com_dev *ena_dev = adapter->ena_dev; @@ -2562,7 +2562,8 @@ static void ena_destroy_device(struct en dev_up = test_bit(ENA_FLAG_DEV_UP, &adapter->flags); adapter->dev_up_before_reset = dev_up; - ena_com_set_admin_running_state(ena_dev, false); + if (!graceful) + ena_com_set_admin_running_state(ena_dev, false); if (test_bit(ENA_FLAG_DEV_UP, &adapter->flags)) ena_down(adapter); @@ -2664,7 +2665,7 @@ static void ena_fw_reset_device(struct w return; } rtnl_lock(); - ena_destroy_device(adapter); + ena_destroy_device(adapter, false); ena_restore_device(adapter); rtnl_unlock(); } @@ -3466,7 +3467,7 @@ static int ena_suspend(struct pci_dev *p "ignoring device reset request as the device is being suspended\n"); clear_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags); } - ena_destroy_device(adapter); + ena_destroy_device(adapter, true); rtnl_unlock(); return 0; }