From patchwork Tue Mar 7 17:35:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 736308 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 3vd3hw68gNz9s8V; Wed, 8 Mar 2017 04:35:44 +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="dGdqPF7w"; 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 1clJ1R-0004jJ-N9; Tue, 07 Mar 2017 17:35:41 +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 1clJ1L-0004iE-08 for kernel-team@lists.ubuntu.com; Tue, 07 Mar 2017 17:35:35 +0000 Received: by mail-io0-f180.google.com with SMTP id z13so10423334iof.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=dT75+p31LeX8MJtVneIHH09dqx1lK10PLYk5OO1tWkA=; b=dGdqPF7wl41B9SYHSPUwf4v4wUnue8E1dP9mah1GeOPBrLrfP4+/QdjpvTtGm1Aa3w WXB9ZIKH+c8Nu8qPGWR7X/4SKwTMsKm1fz4Be8mjLQscCG92SjTR02HMYOup+ByXnWS5 s8A6f1w4TGwsvqnSegH2TiZLTLnJ+uVbBpEw//wBcG7CqhzDZhcDQa7XwMOZhhE4C9iK 8NW2KCscY/uVoGdiYZHJGzXwyfCW7IROE5aYF3bCBx1lmlYCIzOM0UpOuVRKLfpR2Nzv 0aZqPbTSFhYsfKtI8W34albqH2Z1mfEjM1cjJe42PVupZe1+rwBTXOSu5CVhz9yv/PPf UaBw== 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=dT75+p31LeX8MJtVneIHH09dqx1lK10PLYk5OO1tWkA=; b=pTEYX+EgLjnjcNnyAEiDABBHKPbklsnXmbkXo6Ox5NomMkVr0g0yzhF6Fw68WUsDVU 6KkuLMQQ46IVDpG79u2cs/gOcVEXJGCrGem7zHrXD9nZwP6QVJ4qhu/JBrOuO/g3KAyC Jhas6l7Rb3VCtTLnEcWgYn704T2IfaGHqKA/zpT6PaBoUUAdgdZE+0HSxIW4Qh8VassJ y66XBzMJfcqU3WaAu6j8yDdMaGqbF+kNouaRF9fiMwOY9Emt/u7vjFJclcTpzoNFVt9/ +mVBhVdKb9Prca37ogwUW2neNrbYQXtIGhvMXcgptKsMvMpN3ZfwfRRqR3NH+F09UuFI +zOw== X-Gm-Message-State: AMke39mc4/qgxDD4D2ijg6fPL43ul8YiVg7Kp/hWDAxi/nfDa4GK+ouPQ5WJojKtKM5xBXhJ X-Received: by 10.107.129.75 with SMTP id c72mr2292204iod.23.1488908133735; Tue, 07 Mar 2017 09:35:33 -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:33 -0800 (PST) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/4] PCI: hv: Delete the device earlier from hbus->children for hot-remove Date: Tue, 7 Mar 2017 10:35:24 -0700 Message-Id: <1488908126-2221-3-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 After we send a PCI_EJECTION_COMPLETE message to the host, the host will immediately send us a PCI_BUS_RELATIONS message with relations->device_count == 0, so pci_devices_present_work(), running on another thread, can find the being-ejected device, mark the hpdev->reported_missing to true, and run list_move_tail()/list_del() for the device -- this races hv_eject_device_work() -> list_del(). Move the list_del() in hv_eject_device_work() to an earlier place, i.e., before we send PCI_EJECTION_COMPLETE, so later the pci_devices_present_work() can't see the device. 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 e74d2ebdda33b3bdd1826b5b92e9aa45bdf92bb3) Signed-off-by: Tim Gardner --- drivers/pci/host/pci-hyperv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index a290e79..10bc3a0 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -1600,6 +1600,10 @@ static void hv_eject_device_work(struct work_struct *work) pci_unlock_rescan_remove(); } + spin_lock_irqsave(&hpdev->hbus->device_list_lock, flags); + list_del(&hpdev->list_entry); + spin_unlock_irqrestore(&hpdev->hbus->device_list_lock, flags); + memset(&ctxt, 0, sizeof(ctxt)); ejct_pkt = (struct pci_eject_response *)&ctxt.pkt.message; ejct_pkt->message_type.type = PCI_EJECTION_COMPLETE; @@ -1608,10 +1612,6 @@ static void hv_eject_device_work(struct work_struct *work) sizeof(*ejct_pkt), (unsigned long)&ctxt.pkt, VM_PKT_DATA_INBAND, 0); - spin_lock_irqsave(&hpdev->hbus->device_list_lock, flags); - list_del(&hpdev->list_entry); - spin_unlock_irqrestore(&hpdev->hbus->device_list_lock, flags); - put_pcichild(hpdev, hv_pcidev_ref_childlist); put_pcichild(hpdev, hv_pcidev_ref_pnp); put_hvpcibus(hpdev->hbus);