From patchwork Tue Mar 7 17:30:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 736305 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 3vd3bh6JmFz9s8V; Wed, 8 Mar 2017 04:31:12 +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="Lv2+N5Dz"; 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 1clIx3-0004IT-HH; Tue, 07 Mar 2017 17:31:09 +0000 Received: from mail-io0-f180.google.com ([209.85.223.180]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1clIwq-0004D9-Jk for kernel-team@lists.ubuntu.com; Tue, 07 Mar 2017 17:30:56 +0000 Received: by mail-io0-f180.google.com with SMTP id f84so9171423ioj.0 for ; Tue, 07 Mar 2017 09:30:56 -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=qyy2RIG+3OxcODu2Ky/LCXuz0+r5eYbipOkESjn5B7k=; b=Lv2+N5DzxI+2oLwTHKVStS6Fg7BLKpNmsysxvGsMRzwJcnz63hbZ9BksQiwCrLTEBb b+auzPvE5Yrc7/daZSkiDmuU63UB22Fxj6UkP7NFtBid+oGl4PpIF2ab2HCocOYudCXN UPaRvVclaXxruvcTUqd9n7eCTmhZl1yS5E6SCJF+6eqNTkxDfqvS0CK5JgyFJXU1Ke/I gEQwKoBmKu85uDkoKgwXiRutuKKZjGyxhSD73CcuKHbyyjzIjmAFr/fi+EN+IclQ4RSn Zu7OyAFq3KSpYXgJlrzSyq2KfJT0HsgK2NqyN28pTfwynnR4riiuA1S9h6UrWrb+xwnv /K7A== 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=qyy2RIG+3OxcODu2Ky/LCXuz0+r5eYbipOkESjn5B7k=; b=bxKH9sJ9zLGPEDnd5u9v2M3iXZ6eLev2JPWQAG0swM4eTHrw0Lfchf9wiQmT7zLZJs 2ycUhghEhknueDiW+hF8fu8ciPQsJZETEb7GgZGBAMsL3UtX423/z3QwtUbZ5L4tTmLU xJV7eMk5Bf9sgduzvI1UppVrzamn996cNrS+3GOI9Q17Bd2U4Orn/Szfuj81LJ8p1Dym aJelDs80XIp8dBxzhfXZMOC5tNkQ25h2ho0BszuMRwFGrAnsiV0SwPlxgRz3qIk2pr9e 3XuTDHsLn4mecUqX6cX/quv7DEdE6gjRs+pkcgxiXIogIl3clk6KcgtMJKBbUIPRbuTq RFOw== X-Gm-Message-State: AMke39l4+zvYQNaxvgjN1bM+jhdFpHq6NNRJ8g1UNXoLhBljQpdw0itGw1OJ05nfjuU0ADP+ X-Received: by 10.107.204.2 with SMTP id c2mr1963276iog.202.1488907855069; Tue, 07 Mar 2017 09:30:55 -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 a21sm6521285itc.28.2017.03.07.09.30.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Mar 2017 09:30:54 -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:30:45 -0700 Message-Id: <1488907848-1872-2-git-send-email-tim.gardner@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488907848-1872-1-git-send-email-tim.gardner@canonical.com> References: <1488907848-1872-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 763ff87..c968330 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -2266,24 +2266,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); @@ -2298,7 +2306,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(); @@ -2307,17 +2327,10 @@ static int hv_pci_remove(struct hv_device *hdev) pci_unlock_rescan_remove(); } - 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);