From patchwork Thu Apr 5 17:55:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 895478 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) 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]) by ozlabs.org (Postfix) with ESMTP id 40H9VK4Rrqz9s2B; Fri, 6 Apr 2018 03:55:53 +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 1f496y-000700-S6; Thu, 05 Apr 2018 17:55:48 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1f496w-0006zp-QP for kernel-team@lists.ubuntu.com; Thu, 05 Apr 2018 17:55:46 +0000 Received: from mail-qt0-f200.google.com ([209.85.216.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1f496w-0000TP-Ds for kernel-team@lists.ubuntu.com; Thu, 05 Apr 2018 17:55:46 +0000 Received: by mail-qt0-f200.google.com with SMTP id q19so18225610qta.17 for ; Thu, 05 Apr 2018 10:55:46 -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; bh=+G+RhdNH4Su4gXmI1dYvNSdsGEn1ROYiLcvFGpdQVkM=; b=SsNl4ozhYIbGQCLq3PgaQOt7D1geJ5Z6zTS7p2YvndlFdgESWe/KzcOCpE413k10Ks MLx7gK1ohmi+Gw3L42z9Ha5ukO0+7qoBYtjy/BSE+YzJWxBKtuCzgxABgg73njEBdcy5 6xcv6ePHXgMum9bDREBz/mF+8UIHH6pQrKuYVNIRxNv+SmgmDq7DIRhnzqBbWDe1Yoia qgriAe4NlljCSQViw67wDAbyKQaMyJjWtN2YzRhvu+D4glIeyNQSDNsx8On5IcymqUSn Owj3IDtz/WAgP6fa3wlvimp7OLDWV0sx70c1CwX1sCJ+4Xcc/F+/E5BR0oEHmTQC/8mq gMeg== X-Gm-Message-State: ALQs6tCik0jDdgV4y+cOWnoNLd3k0dHpSsoNymKcXUuhSM67SD7ynDxx ZOvmzDa4U/ssEOdaveU6xF7tPfMWmcU5G8dKgsoYgA8wEzGV/+K08XK6Lk+M6LlmFGidJpqhE+L lHX1YmUvpxPHy/OdIBGStCssJmxPZN27ZT69SXEKI X-Received: by 10.200.42.146 with SMTP id b18mr33422177qta.262.1522950945171; Thu, 05 Apr 2018 10:55:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/ixWi17ZVcqA0hZR4MzWHX4Y3VVntWqyhkuYmiTLX7kDJp6x+O/jBxdggV4kk1pIWsJjgDPQ== X-Received: by 10.200.42.146 with SMTP id b18mr33422154qta.262.1522950944885; Thu, 05 Apr 2018 10:55:44 -0700 (PDT) Received: from localhost.localdomain ([191.8.81.129]) by smtp.gmail.com with ESMTPSA id m53sm6854230qtf.67.2018.04.05.10.55.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 10:55:43 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [azure:x][PATCH 1/5] UBUNTU: SAUCE: PCI: hv: Serialize the present and eject work items Date: Thu, 5 Apr 2018 14:55:30 -0300 Message-Id: <1522950934-8127-2-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522950934-8127-1-git-send-email-marcelo.cerri@canonical.com> References: <1522950934-8127-1-git-send-email-marcelo.cerri@canonical.com> 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: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Dexuan Cui BugLink: http://bugs.launchpad.net/bugs/1758378 When we hot-remove the device, we first receive a PCI_EJECT message and then receive a PCI_BUS_RELATIONS message with bus_rel->device_count == 0. The first message is offloaded to hv_eject_device_work(), and the second is offloaded to pci_devices_present_work(). Both the paths can be running list_del(&hpdev->list_entry), causing general protection fault, because system_wq can run them concurrently. The patch eliminates the race condition. Since access to present/eject work items is serialized, we do not need the hbus->enum_sem anymore, so remove it. Fixes: 4daace0d8ce8 ("PCI: hv: Add paravirtual PCI front-end for Microsoft Hyper-V VMs") Link: https://lkml.kernel.org/r/KL1P15301MB00064DA6B4D221123B5241CFBFD70@KL1P15301MB0006.APCP153.PROD.OUTLOOK.COM Tested-by: Adrian Suhov Tested-by: Chris Valean Signed-off-by: Dexuan Cui [lorenzo.pieralisi@arm.com: squashed semaphore removal patch] Signed-off-by: Lorenzo Pieralisi Reviewed-by: Michael Kelley Acked-by: Haiyang Zhang Cc: # v4.6+ Cc: Vitaly Kuznetsov Cc: Jack Morgenstein Cc: Stephen Hemminger Cc: K. Y. Srinivasan Signed-off-by: Marcelo Henrique Cerri --- drivers/pci/host/pci-hyperv.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 8b5f66d3c4f2..f699af20c012 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -457,7 +457,6 @@ struct hv_pcibus_device { spinlock_t device_list_lock; /* Protect lists below */ void __iomem *cfg_addr; - struct semaphore enum_sem; struct list_head resources_for_children; struct list_head children; @@ -471,6 +470,8 @@ struct hv_pcibus_device { struct retarget_msi_interrupt retarget_msi_interrupt_params; spinlock_t retarget_msi_interrupt_lock; + + struct workqueue_struct *wq; }; /* @@ -1606,12 +1607,8 @@ static struct hv_pci_dev *get_pcichild_wslot(struct hv_pcibus_device *hbus, * It must also treat the omission of a previously observed device as * notification that the device no longer exists. * - * Note that this function is a work item, and it may not be - * invoked in the order that it was queued. Back to back - * updates of the list of present devices may involve queuing - * multiple work items, and this one may run before ones that - * were sent later. As such, this function only does something - * if is the last one in the queue. + * Note that this function is serialized with hv_eject_device_work(), + * because both are pushed to the ordered workqueue hbus->wq. */ static void pci_devices_present_work(struct work_struct *work) { @@ -1632,11 +1629,6 @@ static void pci_devices_present_work(struct work_struct *work) INIT_LIST_HEAD(&removed); - if (down_interruptible(&hbus->enum_sem)) { - put_hvpcibus(hbus); - return; - } - /* Pull this off the queue and process it if it was the last one. */ spin_lock_irqsave(&hbus->device_list_lock, flags); while (!list_empty(&hbus->dr_list)) { @@ -1653,7 +1645,6 @@ static void pci_devices_present_work(struct work_struct *work) spin_unlock_irqrestore(&hbus->device_list_lock, flags); if (!dr) { - up(&hbus->enum_sem); put_hvpcibus(hbus); return; } @@ -1740,7 +1731,6 @@ static void pci_devices_present_work(struct work_struct *work) break; } - up(&hbus->enum_sem); put_hvpcibus(hbus); kfree(dr); } @@ -1786,7 +1776,7 @@ static void hv_pci_devices_present(struct hv_pcibus_device *hbus, spin_unlock_irqrestore(&hbus->device_list_lock, flags); get_hvpcibus(hbus); - schedule_work(&dr_wrk->wrk); + queue_work(hbus->wq, &dr_wrk->wrk); } /** @@ -1864,7 +1854,7 @@ static void hv_pci_eject_device(struct hv_pci_dev *hpdev) get_pcichild(hpdev, hv_pcidev_ref_pnp); INIT_WORK(&hpdev->wrk, hv_eject_device_work); get_hvpcibus(hpdev->hbus); - schedule_work(&hpdev->wrk); + queue_work(hpdev->hbus->wq, &hpdev->wrk); } /** @@ -2477,13 +2467,18 @@ static int hv_pci_probe(struct hv_device *hdev, spin_lock_init(&hbus->config_lock); spin_lock_init(&hbus->device_list_lock); spin_lock_init(&hbus->retarget_msi_interrupt_lock); - sema_init(&hbus->enum_sem, 1); init_completion(&hbus->remove_event); + hbus->wq = alloc_ordered_workqueue("hv_pci_%x", 0, + hbus->sysdata.domain); + if (!hbus->wq) { + ret = -ENOMEM; + goto free_bus; + } ret = vmbus_open(hdev->channel, pci_ring_size, pci_ring_size, NULL, 0, hv_pci_onchannelcallback, hbus); if (ret) - goto free_bus; + goto destroy_wq; hv_set_drvdata(hdev, hbus); @@ -2552,6 +2547,8 @@ static int hv_pci_probe(struct hv_device *hdev, hv_free_config_window(hbus); close: vmbus_close(hdev->channel); +destroy_wq: + destroy_workqueue(hbus->wq); free_bus: free_page((unsigned long)hbus); return ret; @@ -2631,6 +2628,7 @@ static int hv_pci_remove(struct hv_device *hdev) irq_domain_free_fwnode(hbus->sysdata.fwnode); put_hvpcibus(hbus); wait_for_completion(&hbus->remove_event); + destroy_workqueue(hbus->wq); free_page((unsigned long)hbus); return 0; } From patchwork Thu Apr 5 17:55:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 895480 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) 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]) by ozlabs.org (Postfix) with ESMTP id 40H9VM0Ytfz9rxp; Fri, 6 Apr 2018 03:55:55 +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 1f4971-00070s-0W; Thu, 05 Apr 2018 17:55:51 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1f496z-000707-3G for kernel-team@lists.ubuntu.com; Thu, 05 Apr 2018 17:55:49 +0000 Received: from mail-qk0-f200.google.com ([209.85.220.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1f496y-0000TZ-Mz for kernel-team@lists.ubuntu.com; Thu, 05 Apr 2018 17:55:48 +0000 Received: by mail-qk0-f200.google.com with SMTP id r138so17333521qke.18 for ; Thu, 05 Apr 2018 10:55:48 -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; bh=M7XYT/72A+Tswdx/rP6twuBRLzbYVMlkjbxEMuEb5hc=; b=lmuEgC2o8DD887hhmiAayk9SG9ZJOUFqA6voIeFNrAEANmFGAUlWf7zNUCCJzx4ZpH aksheyDimX1CvQZznnGEce3WbNPVI2+H/SaFh/Q6wtKktb1yk61j4Xgv0tNe+KRKY+Rr lxifaQ7aeUQY4LUlmid/7PehBk6Ukdlwu4y12HnG2QiYnJFSeBzD8GDNBrleO213Ulcy HTBt432ENJdq5mpAT/PkM1lRNDk85rx+aR1oGkBPKAftyAgYp2yk0wlw8W0opN4SuKVo EJ6rpaaEukA5qqjNZbzrfsUYCniy5Mej0iEsvxFE1NmklwhlKosFSdecnV247MHdaSfJ GBcg== X-Gm-Message-State: ALQs6tBUJiTNC/neadaZY8gp8xR6r3dCWxpZYl6SpmRTFyL6s1SGrhCe BGqxafZLOfYvwV4Mj4pPsv8zhHq5Rt1ym8Cr2BnB6ZLJbioflUxJp2+hKwpbm52uxOCgZT03Gy9 Js4rrFmSOxISKFUAOgoyz5KuudA36HA4a70lGtIKX X-Received: by 10.237.43.228 with SMTP id e91mr12847685qtd.17.1522950947412; Thu, 05 Apr 2018 10:55:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/XB2pJzjpxrE5OfW29GLCeOw5zSRhimonkbFSHVZUX0jTinrlD3S9eoIPC+15jmQKrGtHvYw== X-Received: by 10.237.43.228 with SMTP id e91mr12847661qtd.17.1522950947123; Thu, 05 Apr 2018 10:55:47 -0700 (PDT) Received: from localhost.localdomain ([191.8.81.129]) by smtp.gmail.com with ESMTPSA id m53sm6854230qtf.67.2018.04.05.10.55.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 10:55:46 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [azure:x][PATCH 2/5] UBUNTU: SAUCE: PCI: hv: Fix 2 hang issues in hv_compose_msi_msg() Date: Thu, 5 Apr 2018 14:55:31 -0300 Message-Id: <1522950934-8127-3-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522950934-8127-1-git-send-email-marcelo.cerri@canonical.com> References: <1522950934-8127-1-git-send-email-marcelo.cerri@canonical.com> 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: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Dexuan Cui BugLink: http://bugs.launchpad.net/bugs/1758378 1. With the patch "x86/vector/msi: Switch to global reservation mode", the recent v4.15 and newer kernels always hang for 1-vCPU Hyper-V VM with SR-IOV. This is because when we reach hv_compose_msi_msg() by request_irq() -> request_threaded_irq() ->__setup_irq()->irq_startup() -> __irq_startup() -> irq_domain_activate_irq() -> ... -> msi_domain_activate() -> ... -> hv_compose_msi_msg(), local irq is disabled in __setup_irq(). Note: when we reach hv_compose_msi_msg() by another code path: pci_enable_msix_range() -> ... -> irq_domain_activate_irq() -> ... -> hv_compose_msi_msg(), local irq is not disabled. hv_compose_msi_msg() depends on an interrupt from the host. With interrupts disabled, a UP VM always hangs in the busy loop in the function, because the interrupt callback hv_pci_onchannelcallback() can not be called. We can do nothing but work it around by polling the channel. This is ugly, but we don't have any other choice. 2. If the host is ejecting the VF device before we reach hv_compose_msi_msg(), in a UP VM, we can hang in hv_compose_msi_msg() forever, because at this time the host doesn't respond to the CREATE_INTERRUPT request. This issue exists the first day the pci-hyperv driver appears in the kernel. Luckily, this can also by worked around by polling the channel for the PCI_EJECT message and hpdev->state, and by checking the PCI vendor ID. Note: actually the above 2 issues also happen to a SMP VM, if "hbus->hdev->channel->target_cpu == smp_processor_id()" is true. Fixes: 4900be83602b ("x86/vector/msi: Switch to global reservation mode") Tested-by: Adrian Suhov Tested-by: Chris Valean Signed-off-by: Dexuan Cui Signed-off-by: Lorenzo Pieralisi Reviewed-by: Michael Kelley Acked-by: Haiyang Zhang Cc: Cc: Stephen Hemminger Cc: K. Y. Srinivasan Cc: Vitaly Kuznetsov Cc: Jack Morgenstein Signed-off-by: Marcelo Henrique Cerri --- drivers/pci/host/pci-hyperv.c | 58 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index f699af20c012..77bdb70e36f3 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -531,6 +531,8 @@ struct hv_pci_compl { s32 completion_status; }; +static void hv_pci_onchannelcallback(void *context); + /** * hv_pci_generic_compl() - Invoked for a completion packet * @context: Set up by the sender of the packet. @@ -675,6 +677,31 @@ static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, } } +static u16 hv_pcifront_get_vendor_id(struct hv_pci_dev *hpdev) +{ + u16 ret; + unsigned long flags; + void __iomem *addr = hpdev->hbus->cfg_addr + CFG_PAGE_OFFSET + + PCI_VENDOR_ID; + + spin_lock_irqsave(&hpdev->hbus->config_lock, flags); + + /* Choose the function to be read. (See comment above) */ + writel(hpdev->desc.win_slot.slot, hpdev->hbus->cfg_addr); + /* Make sure the function was chosen before we start reading. */ + mb(); + /* Read from that function's config space. */ + ret = readw(addr); + /* + * mb() is not required here, because the spin_unlock_irqrestore() + * is a barrier. + */ + + spin_unlock_irqrestore(&hpdev->hbus->config_lock, flags); + + return ret; +} + /** * _hv_pcifront_write_config() - Internal PCI config write * @hpdev: The PCI driver's representation of the device @@ -1121,8 +1148,37 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) * Since this function is called with IRQ locks held, can't * do normal wait for completion; instead poll. */ - while (!try_wait_for_completion(&comp.comp_pkt.host_event)) + while (!try_wait_for_completion(&comp.comp_pkt.host_event)) { + /* 0xFFFF means an invalid PCI VENDOR ID. */ + if (hv_pcifront_get_vendor_id(hpdev) == 0xFFFF) { + dev_err_once(&hbus->hdev->device, + "the device has gone\n"); + goto free_int_desc; + } + + /* + * When the higher level interrupt code calls us with + * interrupt disabled, we must poll the channel by calling + * the channel callback directly when channel->target_cpu is + * the current CPU. When the higher level interrupt code + * calls us with interrupt enabled, let's add the + * local_bh_disable()/enable() to avoid race. + */ + local_bh_disable(); + + if (hbus->hdev->channel->target_cpu == smp_processor_id()) + hv_pci_onchannelcallback(hbus); + + local_bh_enable(); + + if (hpdev->state == hv_pcichild_ejecting) { + dev_err_once(&hbus->hdev->device, + "the device is being ejected\n"); + goto free_int_desc; + } + udelay(100); + } if (comp.comp_pkt.completion_status < 0) { dev_err(&hbus->hdev->device, From patchwork Thu Apr 5 17:55:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 895481 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) 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]) by ozlabs.org (Postfix) with ESMTP id 40H9VN3Lwpz9s2R; Fri, 6 Apr 2018 03:55:56 +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 1f4972-00071v-Bh; Thu, 05 Apr 2018 17:55:52 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1f4971-00070p-3i for kernel-team@lists.ubuntu.com; Thu, 05 Apr 2018 17:55:51 +0000 Received: from mail-qk0-f198.google.com ([209.85.220.198]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1f4970-0000Tj-Pu for kernel-team@lists.ubuntu.com; Thu, 05 Apr 2018 17:55:50 +0000 Received: by mail-qk0-f198.google.com with SMTP id z128so17352701qka.8 for ; Thu, 05 Apr 2018 10:55:50 -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; bh=iBOD0fB4MdNWg3LBAfL1j2ps2M9LrPJcuvVSG7WTH6k=; b=BpnWXocepCMrv5I+RPW/slNMEOK3/CM4lDBBG3zuCLFFre1CEb1AKWFX+F/EtatQk6 iFwWCf8YaKgExG2IShrh7zo1w3sxKH4G7xeQs2HS6BGPzaajwbtB3BzM0kfXtB1xC2MH 9Eq1/sMQ5cI/kYs5IjPmF8uHd6csHjKnD7OIvC9hWwhQVC6u9hv9ikGy/Pvn5Aje2lI5 Nj9ZitwtoAWSmxcLhTo0njgauzJIMmp/z0B8ub5fj9DriT54T1QY/Kj7L5IFqqBzoFM3 p8W6Yje3ccDWIoWlOsJLiOqdX9Q+7929Jg0q8EzJnftYuDTt+y0027RYHBhAs5mbAvhU wXEg== X-Gm-Message-State: ALQs6tAOElyJnu0c6mUGe8me+lmnZ1YbOu+Cr1vJSFcShrTgW3B7fg7Z Yip14yD+6CoSsrQCeU4LouT4IlQ0eno2lpzZyUjAZHk87tWS8Ka5wUNPid/I0G6diwLDgiVcnOC inidDl1xBmk+x5oleAJjpiDnAw2ARDOSodeteIT30 X-Received: by 10.55.32.71 with SMTP id g68mr30189970qkg.129.1522950949534; Thu, 05 Apr 2018 10:55:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx48rCNbhoayMiHkX+QVv7sRYPHGkltV9biFLtN6YyeskD5FU/Eq4l6zGstqDOnb/b350PQnC/A== X-Received: by 10.55.32.71 with SMTP id g68mr30189959qkg.129.1522950949280; Thu, 05 Apr 2018 10:55:49 -0700 (PDT) Received: from localhost.localdomain ([191.8.81.129]) by smtp.gmail.com with ESMTPSA id m53sm6854230qtf.67.2018.04.05.10.55.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 10:55:48 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [azure:x][PATCH 3/5] UBUNTU: SAUCE: PCI: hv: Fix a comment typo in _hv_pcifront_read_config() Date: Thu, 5 Apr 2018 14:55:32 -0300 Message-Id: <1522950934-8127-4-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522950934-8127-1-git-send-email-marcelo.cerri@canonical.com> References: <1522950934-8127-1-git-send-email-marcelo.cerri@canonical.com> 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: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Dexuan Cui BugLink: http://bugs.launchpad.net/bugs/1758378 Comment in _hv_pcifront_read_config() contains a typo, fix it. No functional change. Signed-off-by: Dexuan Cui [lorenzo.pieralisi@arm.com: changed commit log] Signed-off-by: Lorenzo Pieralisi Acked-by: Haiyang Zhang Cc: Vitaly Kuznetsov Cc: Stephen Hemminger Cc: K. Y. Srinivasan Signed-off-by: Marcelo Henrique Cerri --- drivers/pci/host/pci-hyperv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 77bdb70e36f3..3216bf73fafa 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -666,7 +666,7 @@ static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, break; } /* - * Make sure the write was done before we release the spinlock + * Make sure the read was done before we release the spinlock * allowing consecutive reads/writes. */ mb(); From patchwork Thu Apr 5 17:55:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 895482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) 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]) by ozlabs.org (Postfix) with ESMTP id 40H9VQ5pYzz9s27; Fri, 6 Apr 2018 03:55:58 +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 1f4974-000746-Kk; Thu, 05 Apr 2018 17:55:54 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1f4973-00072m-7T for kernel-team@lists.ubuntu.com; Thu, 05 Apr 2018 17:55:53 +0000 Received: from mail-qk0-f199.google.com ([209.85.220.199]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1f4972-0000Tr-Tw for kernel-team@lists.ubuntu.com; Thu, 05 Apr 2018 17:55:53 +0000 Received: by mail-qk0-f199.google.com with SMTP id o63so805199qki.12 for ; Thu, 05 Apr 2018 10:55:52 -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; bh=yXmHDw4BJdDgw8073eQzX/gAeGy8ntoHQxjJBKnjN2I=; b=WS3zsjuITh2G84py/BxrmFRmGUThSK/XrY9Iv1LerYuTHu3I2fEtPQoafYQwArdqHr B4JU+fpVyobrUPxsh5/MZC5VFiaYFiqVxiIrHg4FDJ2vPmt/VNOQXiiYpzp/5QGVn06R yzaeqVAPwLx6NrmKWgW6B/I9rhhB00QJOAkaXe3YRiA3huO1wCDac+beKj27NMZDNz8a BttTrdEXQxXytG509q/rRk66g7InhIM4veK8RYwLZYsHt0FA45EdLMTKojYxnNDq/o3u EOzXzihDBNVOFgXA1BICvvCOID1YS1NpCqj0rfv4DNAmjguehmrawRIespqSi1ZsssLJ gzcQ== X-Gm-Message-State: ALQs6tCWuv9xQd6jlO4Mvg8s8Pm4QO3+1hMh/ieaagSl891JNGw2wu1O bkPVRUal+ORY6j0l5kOv0w2Cb4UhRYtqdTnVO4z3FcqEADMNZZGsOogK9I+UheLtuKGxZbD6M4M U01YCC12EiJY34xa6Uus/wbI0dexcx7aU7LnkO3Iq X-Received: by 10.55.11.18 with SMTP id 18mr32020718qkl.169.1522950951671; Thu, 05 Apr 2018 10:55:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+E1GkyE3gsEFoJhA4+6e0fMmc7Db3VO/bwWqXSgfQm7WG+H5spMKj37kkzlMQ0iZwQgqH6Lw== X-Received: by 10.55.11.18 with SMTP id 18mr32020701qkl.169.1522950951422; Thu, 05 Apr 2018 10:55:51 -0700 (PDT) Received: from localhost.localdomain ([191.8.81.129]) by smtp.gmail.com with ESMTPSA id m53sm6854230qtf.67.2018.04.05.10.55.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 10:55:50 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [azure:x][PATCH 4/5] UBUNTU: SAUCE: PCI: hv: Remove the bogus test in hv_eject_device_work() Date: Thu, 5 Apr 2018 14:55:33 -0300 Message-Id: <1522950934-8127-5-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522950934-8127-1-git-send-email-marcelo.cerri@canonical.com> References: <1522950934-8127-1-git-send-email-marcelo.cerri@canonical.com> 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: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Dexuan Cui BugLink: http://bugs.launchpad.net/bugs/1758378 When kernel is executing hv_eject_device_work(), hpdev->state value must be hv_pcichild_ejecting; any other value would consist in a bug, therefore replace the bogus check with an explicit WARN_ON() on the condition failure detection. Signed-off-by: Dexuan Cui [lorenzo.pieralisi@arm.com: updated commit log] Signed-off-by: Lorenzo Pieralisi Reviewed-by: Michael Kelley Acked-by: Haiyang Zhang Cc: Vitaly Kuznetsov Cc: Jack Morgenstein Cc: Stephen Hemminger Cc: K. Y. Srinivasan Signed-off-by: Marcelo Henrique Cerri --- drivers/pci/host/pci-hyperv.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 3216bf73fafa..f639be35381b 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -1858,10 +1858,7 @@ static void hv_eject_device_work(struct work_struct *work) hpdev = container_of(work, struct hv_pci_dev, wrk); - if (hpdev->state != hv_pcichild_ejecting) { - put_pcichild(hpdev, hv_pcidev_ref_pnp); - return; - } + WARN_ON(hpdev->state != hv_pcichild_ejecting); /* * Ejection can come before or after the PCI bus has been set up, so From patchwork Thu Apr 5 17:55:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 895483 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) 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]) by ozlabs.org (Postfix) with ESMTP id 40H9VS0HwKz9rxp; Fri, 6 Apr 2018 03:56:00 +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 1f4976-00076R-R4; Thu, 05 Apr 2018 17:55:56 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1f4975-00074i-Ay for kernel-team@lists.ubuntu.com; Thu, 05 Apr 2018 17:55:55 +0000 Received: from mail-qk0-f200.google.com ([209.85.220.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1f4975-0000Tw-0y for kernel-team@lists.ubuntu.com; Thu, 05 Apr 2018 17:55:55 +0000 Received: by mail-qk0-f200.google.com with SMTP id a125so17491659qkd.4 for ; Thu, 05 Apr 2018 10:55:54 -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; bh=HHspJjWZ0TqKdmJNudiMaSe7PADCFM+ij+qdaulQROY=; b=TvvFjXn5mGTKnJ78FLKfhKI3hOhSlICUFSmKqvKF5xY8s0g5e0SHp/aE/BUMLelGmJ iIm/d00mQRLE5yAgIEajmff8UypBjT2j46kl9HJ4TfUPmilAjKK49paJFTE74T42+Lek o15ynBnsdjIkr8e09pIebblJNVLkLzDcPhzqbBkRS1rTuojxjGfbCSAxdOLSxVf2XVyp sB4c5UF02rtwX7SV/8Cd/vpjBQObTW3hG2eKkUVplZ8dHnFIZ410l+NqkGBIK2tLS6YV aOx4yNN9+jZlvCMC6nTZ8eaEe3b56LKlaCiWXSzT5Hrgs7jljbGvrOn4hnebYkrNQKY3 scvQ== X-Gm-Message-State: ALQs6tAAmG8YgbuMOvJEHzQ14mh0fStLFR4OdObT7MGyOV1vPilIjaAY IN6xfS9c0evKuTERyNjx9/akGKP4sW6f3fI7emLSYIuYdeKOWwRpBoP1+qigUUkoq718qLqeZeB uPNzzmbpobTpnBhOi143sDnQPHMEqbXGAg2uihret X-Received: by 10.237.60.155 with SMTP id d27mr33502697qtf.210.1522950953829; Thu, 05 Apr 2018 10:55:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+MkoK+scua0KVjCCXWOTGahP94HA442Ge9s8GK552JyKfoUyEpQhkwng6sMZfgRoBkeZjFGA== X-Received: by 10.237.60.155 with SMTP id d27mr33502679qtf.210.1522950953593; Thu, 05 Apr 2018 10:55:53 -0700 (PDT) Received: from localhost.localdomain ([191.8.81.129]) by smtp.gmail.com with ESMTPSA id m53sm6854230qtf.67.2018.04.05.10.55.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 10:55:52 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [azure:x][PATCH 5/5] UBUNTU: SAUCE: PCI: hv: Only queue new work items in hv_pci_devices_present() if necessary Date: Thu, 5 Apr 2018 14:55:34 -0300 Message-Id: <1522950934-8127-6-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522950934-8127-1-git-send-email-marcelo.cerri@canonical.com> References: <1522950934-8127-1-git-send-email-marcelo.cerri@canonical.com> 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: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Dexuan Cui BugLink: http://bugs.launchpad.net/bugs/1758378 If there is pending work in hv_pci_devices_present() we just need to add the new dr entry into the dr_list. Add a check to detect pending work items and update the code to skip queuing work if pending work items are detected. Signed-off-by: Dexuan Cui [lorenzo.pieralisi@arm.com: updated commit log] Signed-off-by: Lorenzo Pieralisi Reviewed-by: Michael Kelley Acked-by: Haiyang Zhang Cc: Vitaly Kuznetsov Cc: Jack Morgenstein Cc: Stephen Hemminger Cc: K. Y. Srinivasan Signed-off-by: Marcelo Henrique Cerri --- drivers/pci/host/pci-hyperv.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index f639be35381b..415aaad2e924 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -1805,6 +1805,7 @@ static void hv_pci_devices_present(struct hv_pcibus_device *hbus, struct hv_dr_state *dr; struct hv_dr_work *dr_wrk; unsigned long flags; + bool pending_dr; dr_wrk = kzalloc(sizeof(*dr_wrk), GFP_NOWAIT); if (!dr_wrk) @@ -1828,11 +1829,21 @@ static void hv_pci_devices_present(struct hv_pcibus_device *hbus, } spin_lock_irqsave(&hbus->device_list_lock, flags); + /* + * If pending_dr is true, we have already queued a work, + * which will see the new dr. Otherwise, we need to + * queue a new work. + */ + pending_dr = !list_empty(&hbus->dr_list); list_add_tail(&dr->list_entry, &hbus->dr_list); spin_unlock_irqrestore(&hbus->device_list_lock, flags); - get_hvpcibus(hbus); - queue_work(hbus->wq, &dr_wrk->wrk); + if (pending_dr) { + kfree(dr_wrk); + } else { + get_hvpcibus(hbus); + queue_work(hbus->wq, &dr_wrk->wrk); + } } /**