From patchwork Tue Mar 7 17:35:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 736310 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3vd3j43Bh2z9s8V; Wed, 8 Mar 2017 04:35:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="V+EeeKS1"; dkim-atps=neutral Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1clJ1Y-0004mo-VK; Tue, 07 Mar 2017 17:35:48 +0000 Received: from mail-io0-f175.google.com ([209.85.223.175]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1clJ1K-0004i6-3s for kernel-team@lists.ubuntu.com; Tue, 07 Mar 2017 17:35:34 +0000 Received: by mail-io0-f175.google.com with SMTP id z13so10423043iof.2 for ; Tue, 07 Mar 2017 09:35:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=75vH23cHdGh68S7G9zd9NF/o5YpvgBMEQet751ai944=; b=V+EeeKS1oxpHntutGfuM70duKz3S/yWP++TOh9I7NFPCtkt4qI/la9klkxIzT4zYML Vl1Z1CR80ODwiYT3GX/S5GxzMeL8swuDSRiSt6+CgATrFs9cffpEN2fbTxjTZ5XRLaHy omUnJepSXG7JDV700rzz8lcYSmDegmkDbTr4L+gGmeYe6N1w8u0tdde+op/4hziblW0c L9KElJuyWzCF9qcKOAG5yG1gBtAOU3DYQ94WbQT++MCGjZ4Fo4o2SPy0hh3IqDw7sSPo a9F5lq617HWHKlDci2adnJNqAXqz0vHQGnxAw5xJXBtK2u2oIGaon2EwzrU2facb2Pym NBdQ== 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; bh=75vH23cHdGh68S7G9zd9NF/o5YpvgBMEQet751ai944=; b=s9XidU0+Lz9HZJD3zOa5Q1wf4wWlyEeOKqTPZ0zzSK7fmnDb8DqSv3ENMho6XOMjD9 7YrQmRAf3xTWi1I7u5fX+GdxLSM8mA0s/x9ZRTlmUlFae1QoCyuNs40+bOpqJDVr/X1P 9t4g0ymtx8nITXklZqgG9j7XBFQ0mHzOIckx7C6MNksHytvky1yzMUasxtu/sNd40015 jTXLrtCViSL3hqZmSPm79PvTVe7q6aTvKYV4uFdSV63C1dleInZ/0sO7Q07/k1kG3uTT 79QWai/hGmvX9h+b0e65UhP4+JiLSPzSvBCQDwolDgLKqWD1SDvHDYpAKgAR8IVF8AkI cS1w== X-Gm-Message-State: AMke39kJpXs+tWJgJC71rfa/FkyVXfpcn+WIEcGrVWCByrgODdF3xLkMvezhnSbCU0MN7xSW X-Received: by 10.107.173.98 with SMTP id w95mr2096819ioe.32.1488908132754; Tue, 07 Mar 2017 09:35:32 -0800 (PST) Received: from localhost.localdomain (host-98-127-250-84.bln-mt.client.bresnan.net. [98.127.250.84]) by smtp.gmail.com with ESMTPSA id e4sm392819ioe.7.2017.03.07.09.35.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Mar 2017 09:35:32 -0800 (PST) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/4] PCI: hv: Fix hv_pci_remove() for hot-remove Date: Tue, 7 Mar 2017 10:35:23 -0700 Message-Id: <1488908126-2221-2-git-send-email-tim.gardner@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488908126-2221-1-git-send-email-tim.gardner@canonical.com> References: <1488908126-2221-1-git-send-email-tim.gardner@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Dexuan Cui BugLink: http://bugs.launchpad.net/bugs/1670518 1. We don't really need such a big on-stack buffer when sending the teardown_packet: vmbus_sendpacket() here only uses sizeof(struct pci_message). 2. In the hot-remove case (PCI_EJECT), after we send PCI_EJECTION_COMPLETE to the host, the host will send a RESCIND_CHANNEL message to us and the host won't access the per-channel ringbuffer any longer, so we needn't send PCI_RESOURCES_RELEASED/PCI_BUS_D0EXIT to the host, and we shouldn't expect the host's completion message of PCI_BUS_D0EXIT, which will never come. 3. We should send PCI_BUS_D0EXIT after hv_send_resources_released(). Signed-off-by: Dexuan Cui Signed-off-by: Bjorn Helgaas Reviewed-by: Jake Oshins Acked-by: K. Y. Srinivasan CC: Haiyang Zhang CC: Vitaly Kuznetsov (cherry picked from commit 17978524a636d007e6b929304ae3eb5ea0371019) Signed-off-by: Tim Gardner --- drivers/pci/host/pci-hyperv.c | 53 +++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 2bbfdfa..a290e79 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -2285,24 +2285,32 @@ free_bus: return ret; } -/** - * hv_pci_remove() - Remove routine for this VMBus channel - * @hdev: VMBus's tracking struct for this root PCI bus - * - * Return: 0 on success, -errno on failure - */ -static int hv_pci_remove(struct hv_device *hdev) +static void hv_pci_bus_exit(struct hv_device *hdev) { - int ret; - struct hv_pcibus_device *hbus; - union { + struct hv_pcibus_device *hbus = hv_get_drvdata(hdev); + struct { struct pci_packet teardown_packet; - u8 buffer[0x100]; + u8 buffer[sizeof(struct pci_message)]; } pkt; struct pci_bus_relations relations; struct hv_pci_compl comp_pkt; + int ret; - hbus = hv_get_drvdata(hdev); + /* + * After the host sends the RESCIND_CHANNEL message, it doesn't + * access the per-channel ringbuffer any longer. + */ + if (hdev->channel->rescind) + return; + + /* Delete any children which might still exist. */ + memset(&relations, 0, sizeof(relations)); + hv_pci_devices_present(hbus, &relations); + + ret = hv_send_resources_released(hdev); + if (ret) + dev_err(&hdev->device, + "Couldn't send resources released packet(s)\n"); memset(&pkt.teardown_packet, 0, sizeof(pkt.teardown_packet)); init_completion(&comp_pkt.host_event); @@ -2317,7 +2325,19 @@ static int hv_pci_remove(struct hv_device *hdev) VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED); if (!ret) wait_for_completion_timeout(&comp_pkt.host_event, 10 * HZ); +} +/** + * hv_pci_remove() - Remove routine for this VMBus channel + * @hdev: VMBus's tracking struct for this root PCI bus + * + * Return: 0 on success, -errno on failure + */ +static int hv_pci_remove(struct hv_device *hdev) +{ + struct hv_pcibus_device *hbus; + + hbus = hv_get_drvdata(hdev); if (hbus->state == hv_pcibus_installed) { /* Remove the bus from PCI's point of view. */ pci_lock_rescan_remove(); @@ -2327,17 +2347,10 @@ static int hv_pci_remove(struct hv_device *hdev) hbus->state = hv_pcibus_removed; } - ret = hv_send_resources_released(hdev); - if (ret) - dev_err(&hdev->device, - "Couldn't send resources released packet(s)\n"); + hv_pci_bus_exit(hdev); vmbus_close(hdev->channel); - /* Delete any children which might still exist. */ - memset(&relations, 0, sizeof(relations)); - hv_pci_devices_present(hbus, &relations); - iounmap(hbus->cfg_addr); hv_free_config_window(hbus); pci_free_resource_list(&hbus->resources_for_children);