Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/591655/?format=api
{ "id": 591655, "url": "http://patchwork.ozlabs.org/api/patches/591655/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1457049194-9281-10-git-send-email-gwshan@linux.vnet.ibm.com/", "project": { "id": 2, "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api", "name": "Linux PPC development", "link_name": "linuxppc-dev", "list_id": "linuxppc-dev.lists.ozlabs.org", "list_email": "linuxppc-dev@lists.ozlabs.org", "web_url": "https://github.com/linuxppc/wiki/wiki", "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git", "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/", "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/", "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}" }, "msgid": "<1457049194-9281-10-git-send-email-gwshan@linux.vnet.ibm.com>", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/1457049194-9281-10-git-send-email-gwshan@linux.vnet.ibm.com/", "date": "2016-03-03T23:53:11", "name": "[v15,09/12] powerpc/eeh: powerpc/eeh: Support error recovery for VF PE", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "d3b8127881ec179c152a945f132e34c20d571055", "submitter": { "id": 63923, "url": "http://patchwork.ozlabs.org/api/people/63923/?format=api", "name": "Gavin Shan", "email": "gwshan@linux.vnet.ibm.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1457049194-9281-10-git-send-email-gwshan@linux.vnet.ibm.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/591655/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/591655/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>", "X-Original-To": [ "patchwork-incoming@ozlabs.org", "linuxppc-dev@lists.ozlabs.org" ], "Delivered-To": [ "patchwork-incoming@ozlabs.org", "linuxppc-dev@lists.ozlabs.org" ], "Received": [ "from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 971771412CB\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 4 Mar 2016 11:05:51 +1100 (AEDT)", "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 7C3D11A1BE7\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 4 Mar 2016 11:05:51 +1100 (AEDT)", "from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140])\n\t(using TLSv1.2 with cipher CAMELLIA256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 8373A1A0BA8\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri, 4 Mar 2016 10:54:41 +1100 (AEDT)", "from localhost\n\tby e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <linuxppc-dev@lists.ozlabs.org> from <gwshan@linux.vnet.ibm.com>; \n\tFri, 4 Mar 2016 09:54:41 +1000", "from d23dlp01.au.ibm.com (202.81.31.203)\n\tby e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tFri, 4 Mar 2016 09:54:38 +1000", "from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219])\n\tby d23dlp01.au.ibm.com (Postfix) with ESMTP id D88EF2CE8059\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri, 4 Mar 2016 10:54:37 +1100 (EST)", "from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97])\n\tby d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n\tu23NsTbw56295452\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 4 Mar 2016 10:54:37 +1100", "from d23av03.au.ibm.com (localhost [127.0.0.1])\n\tby d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id\n\tu23Ns5A7002711\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 4 Mar 2016 10:54:05 +1100", "from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14])\n\tby d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id\n\tu23Ns5eL002241; Fri, 4 Mar 2016 10:54:05 +1100", "from bran.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114])\n\tby ozlabs.au.ibm.com (Postfix) with ESMTP id D227FA0380;\n\tFri, 4 Mar 2016 10:53:17 +1100 (AEDT)", "from gwshan (shangw.ozlabs.ibm.com [10.61.2.199])\n\tby bran.ozlabs.ibm.com (Postfix) with ESMTP id CE45BE39EB;\n\tFri, 4 Mar 2016 10:53:17 +1100 (AEDT)", "by gwshan (Postfix, from userid 1000)\n\tid BFC639424AF; Fri, 4 Mar 2016 10:53:17 +1100 (AEDT)" ], "X-IBM-Helo": "d23dlp01.au.ibm.com", "X-IBM-MailFrom": "gwshan@linux.vnet.ibm.com", "X-IBM-RcptTo": "linuxppc-dev@lists.ozlabs.org", "From": "Gavin Shan <gwshan@linux.vnet.ibm.com>", "To": "linuxppc-dev@lists.ozlabs.org", "Subject": "[PATCH v15 09/12] powerpc/eeh: powerpc/eeh: Support error recovery\n\tfor VF PE", "Date": "Fri, 4 Mar 2016 10:53:11 +1100", "Message-Id": "<1457049194-9281-10-git-send-email-gwshan@linux.vnet.ibm.com>", "X-Mailer": "git-send-email 2.1.0", "In-Reply-To": "<1457049194-9281-1-git-send-email-gwshan@linux.vnet.ibm.com>", "References": "<1457049194-9281-1-git-send-email-gwshan@linux.vnet.ibm.com>", "X-TM-AS-MML": "disable", "X-Content-Scanned": "Fidelis XPS MAILER", "x-cbid": "16030323-0025-0000-0000-00000311F561", "X-BeenThere": "linuxppc-dev@lists.ozlabs.org", "X-Mailman-Version": "2.1.20", "Precedence": "list", "List-Id": "Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>", "List-Unsubscribe": "<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>", "List-Archive": "<http://lists.ozlabs.org/pipermail/linuxppc-dev/>", "List-Post": "<mailto:linuxppc-dev@lists.ozlabs.org>", "List-Help": "<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>", "List-Subscribe": "<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>", "Cc": "Wei Yang <weiyang@linux.vnet.ibm.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Errors-To": "linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org", "Sender": "\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>" }, "content": "From: Wei Yang <weiyang@linux.vnet.ibm.com>\n\nPFs are enumerated on PCI bus, while VFs are created by PF's driver.\n\nIn EEH recovery, it has two cases:\n1. Device and driver is EEH aware, error handlers are called.\n2. Device and driver is not EEH aware, un-plug the device and plug it again\nby enumerating it.\n\nThe special thing happens on the second case. For a PF, we could use the\noriginal pci core to enumerate the bus, while for VF we need to record the\nVFs which aer un-plugged then plug it again.\n\nAlso The patch caches the VF index in pci_dn, which can be used to\ncalculate VF's bus, device and function number. Those information helps to\nlocate the VF's PCI device instance when doing hotplug during EEH recovery\nif necessary.\n\nSigned-off-by: Wei Yang <weiyang@linux.vnet.ibm.com>\nAcked-by: Gavin Shan <gwshan@linux.vnet.ibm.com>\n---\n arch/powerpc/include/asm/eeh.h | 2 +\n arch/powerpc/include/asm/pci-bridge.h | 1 +\n arch/powerpc/kernel/eeh.c | 8 ++\n arch/powerpc/kernel/eeh_dev.c | 1 +\n arch/powerpc/kernel/eeh_driver.c | 137 +++++++++++++++++++++++++++-------\n arch/powerpc/kernel/pci_dn.c | 4 +-\n 6 files changed, 127 insertions(+), 26 deletions(-)", "diff": "diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h\nindex b5b5f45..fb9f376 100644\n--- a/arch/powerpc/include/asm/eeh.h\n+++ b/arch/powerpc/include/asm/eeh.h\n@@ -140,9 +140,11 @@ struct eeh_dev {\n \tint af_cap;\t\t\t/* Saved AF capability\t\t*/\n \tstruct eeh_pe *pe;\t\t/* Associated PE\t\t*/\n \tstruct list_head list;\t\t/* Form link list in the PE\t*/\n+\tstruct list_head rmv_list;\t/* Record the removed edevs\t*/\n \tstruct pci_controller *phb;\t/* Associated PHB\t\t*/\n \tstruct pci_dn *pdn;\t\t/* Associated PCI device node\t*/\n \tstruct pci_dev *pdev;\t\t/* Associated PCI device\t*/\n+\tbool in_error;\t\t\t/* Error flag for edev\t\t*/\n \tstruct pci_dev *physfn;\t\t/* Associated SRIOV PF\t\t*/\n \tstruct pci_bus *bus;\t\t/* PCI bus for partial hotplug\t*/\n };\ndiff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h\nindex f4d1758..9f165e8 100644\n--- a/arch/powerpc/include/asm/pci-bridge.h\n+++ b/arch/powerpc/include/asm/pci-bridge.h\n@@ -212,6 +212,7 @@ struct pci_dn {\n #define IODA_INVALID_PE\t\t(-1)\n #ifdef CONFIG_PPC_POWERNV\n \tint\tpe_number;\n+\tint vf_index;\t\t/* VF index in the PF */\n #ifdef CONFIG_PCI_IOV\n \tu16 vfs_expanded;\t\t/* number of VFs IOV BAR expanded */\n \tu16 num_vfs;\t\t/* number of VFs enabled*/\ndiff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c\nindex 0d72462..b7338a9 100644\n--- a/arch/powerpc/kernel/eeh.c\n+++ b/arch/powerpc/kernel/eeh.c\n@@ -1246,6 +1246,14 @@ void eeh_remove_device(struct pci_dev *dev)\n \t * from the parent PE during the BAR resotre.\n \t */\n \tedev->pdev = NULL;\n+\n+\t/*\n+\t * The flag \"in_error\" is used to trace EEH devices for VFs\n+\t * in error state or not. It's set in eeh_report_error(). If\n+\t * it's not set, eeh_report_{reset,resume}() won't be called\n+\t * for the VF EEH device.\n+\t */\n+\tedev->in_error = false;\n \tdev->dev.archdata.edev = NULL;\n \tif (!(edev->pe->state & EEH_PE_KEEP))\n \t\teeh_rmv_from_parent_pe(edev);\ndiff --git a/arch/powerpc/kernel/eeh_dev.c b/arch/powerpc/kernel/eeh_dev.c\nindex aabba94..7815095 100644\n--- a/arch/powerpc/kernel/eeh_dev.c\n+++ b/arch/powerpc/kernel/eeh_dev.c\n@@ -67,6 +67,7 @@ void *eeh_dev_init(struct pci_dn *pdn, void *data)\n \tedev->pdn = pdn;\n \tedev->phb = phb;\n \tINIT_LIST_HEAD(&edev->list);\n+\tINIT_LIST_HEAD(&edev->rmv_list);\n \n \treturn NULL;\n }\ndiff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c\nindex 650cfb3..c0fe7a6 100644\n--- a/arch/powerpc/kernel/eeh_driver.c\n+++ b/arch/powerpc/kernel/eeh_driver.c\n@@ -34,6 +34,11 @@\n #include <asm/prom.h>\n #include <asm/rtas.h>\n \n+struct eeh_rmv_data {\n+\tstruct list_head edev_list;\n+\tint removed;\n+};\n+\n /**\n * eeh_pcid_name - Retrieve name of PCI device driver\n * @pdev: PCI device\n@@ -211,6 +216,7 @@ static void *eeh_report_error(void *data, void *userdata)\n \tif (rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;\n \tif (*res == PCI_ERS_RESULT_NONE) *res = rc;\n \n+\tedev->in_error = true;\n \teeh_pcid_put(dev);\n \treturn NULL;\n }\n@@ -282,7 +288,8 @@ static void *eeh_report_reset(void *data, void *userdata)\n \n \tif (!driver->err_handler ||\n \t !driver->err_handler->slot_reset ||\n-\t (edev->mode & EEH_DEV_NO_HANDLER)) {\n+\t (edev->mode & EEH_DEV_NO_HANDLER) ||\n+\t (!edev->in_error)) {\n \t\teeh_pcid_put(dev);\n \t\treturn NULL;\n \t}\n@@ -326,6 +333,7 @@ static void *eeh_report_resume(void *data, void *userdata)\n {\n \tstruct eeh_dev *edev = (struct eeh_dev *)data;\n \tstruct pci_dev *dev = eeh_dev_to_pci_dev(edev);\n+\tbool was_in_error;\n \tstruct pci_driver *driver;\n \n \tif (!dev || eeh_dev_removed(edev))\n@@ -335,11 +343,13 @@ static void *eeh_report_resume(void *data, void *userdata)\n \tdriver = eeh_pcid_get(dev);\n \tif (!driver) return NULL;\n \n+\twas_in_error = edev->in_error;\n+\tedev->in_error = false;\n \teeh_enable_irq(dev);\n \n \tif (!driver->err_handler ||\n \t !driver->err_handler->resume ||\n-\t (edev->mode & EEH_DEV_NO_HANDLER)) {\n+\t (edev->mode & EEH_DEV_NO_HANDLER) || !was_in_error) {\n \t\tedev->mode &= ~EEH_DEV_NO_HANDLER;\n \t\teeh_pcid_put(dev);\n \t\treturn NULL;\n@@ -386,12 +396,40 @@ static void *eeh_report_failure(void *data, void *userdata)\n \treturn NULL;\n }\n \n+static void *eeh_add_virt_device(void *data, void *userdata)\n+{\n+\tstruct pci_driver *driver;\n+\tstruct eeh_dev *edev = (struct eeh_dev *)data;\n+\tstruct pci_dev *dev = eeh_dev_to_pci_dev(edev);\n+\tstruct pci_dn *pdn = eeh_dev_to_pdn(edev);\n+\n+\tif (!(edev->physfn)) {\n+\t\tpr_warn(\"%s: EEH dev %04x:%02x:%02x.%01x not for VF\\n\",\n+\t\t\t__func__, edev->phb->global_number, pdn->busno,\n+\t\t\tPCI_SLOT(pdn->devfn), PCI_FUNC(pdn->devfn));\n+\t\treturn NULL;\n+\t}\n+\n+\tdriver = eeh_pcid_get(dev);\n+\tif (driver) {\n+\t\teeh_pcid_put(dev);\n+\t\tif (driver->err_handler)\n+\t\t\treturn NULL;\n+\t}\n+\n+#ifdef CONFIG_PPC_POWERNV\n+\tpci_iov_add_virtfn(edev->physfn, pdn->vf_index, 0);\n+#endif\n+\treturn NULL;\n+}\n+\n static void *eeh_rmv_device(void *data, void *userdata)\n {\n \tstruct pci_driver *driver;\n \tstruct eeh_dev *edev = (struct eeh_dev *)data;\n \tstruct pci_dev *dev = eeh_dev_to_pci_dev(edev);\n-\tint *removed = (int *)userdata;\n+\tstruct eeh_rmv_data *rmv_data = (struct eeh_rmv_data *)userdata;\n+\tint *removed = rmv_data ? &rmv_data->removed : NULL;\n \n \t/*\n \t * Actually, we should remove the PCI bridges as well.\n@@ -416,7 +454,8 @@ static void *eeh_rmv_device(void *data, void *userdata)\n \tdriver = eeh_pcid_get(dev);\n \tif (driver) {\n \t\teeh_pcid_put(dev);\n-\t\tif (driver->err_handler &&\n+\t\tif (removed &&\n+\t\t driver->err_handler &&\n \t\t driver->err_handler->error_detected &&\n \t\t driver->err_handler->slot_reset)\n \t\t\treturn NULL;\n@@ -427,11 +466,29 @@ static void *eeh_rmv_device(void *data, void *userdata)\n \t\t pci_name(dev));\n \tedev->bus = dev->bus;\n \tedev->mode |= EEH_DEV_DISCONNECTED;\n-\t(*removed)++;\n+\tif (removed)\n+\t\t(*removed)++;\n \n-\tpci_lock_rescan_remove();\n-\tpci_stop_and_remove_bus_device(dev);\n-\tpci_unlock_rescan_remove();\n+\tif (edev->physfn) {\n+#ifdef CONFIG_PPC_POWERNV\n+\t\tstruct pci_dn *pdn = eeh_dev_to_pdn(edev);\n+\n+\t\tpci_iov_remove_virtfn(edev->physfn, pdn->vf_index, 0);\n+\t\tedev->pdev = NULL;\n+\n+\t\t/*\n+\t\t * We have to set the VF PE number to invalid one, which is\n+\t\t * required to plug the VF successfully.\n+\t\t */\n+\t\tpdn->pe_number = IODA_INVALID_PE;\n+#endif\n+\t\tif (rmv_data)\n+\t\t\tlist_add(&edev->rmv_list, &rmv_data->edev_list);\n+\t} else {\n+\t\tpci_lock_rescan_remove();\n+\t\tpci_stop_and_remove_bus_device(dev);\n+\t\tpci_unlock_rescan_remove();\n+\t}\n \n \treturn NULL;\n }\n@@ -545,11 +602,13 @@ int eeh_pe_reset_and_recover(struct eeh_pe *pe)\n * During the reset, udev might be invoked because those affected\n * PCI devices will be removed and then added.\n */\n-static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus)\n+static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus,\n+\t\t\t\tstruct eeh_rmv_data *rmv_data)\n {\n \tstruct pci_bus *frozen_bus = eeh_pe_bus_get(pe);\n \tstruct timeval tstamp;\n-\tint cnt, rc, removed = 0;\n+\tint cnt, rc;\n+\tstruct eeh_dev *edev;\n \n \t/* pcibios will clear the counter; save the value */\n \tcnt = pe->freeze_count;\n@@ -563,12 +622,16 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus)\n \t */\n \teeh_pe_state_mark(pe, EEH_PE_KEEP);\n \tif (bus) {\n-\t\teeh_pe_state_clear(pe, EEH_PE_PRI_BUS);\n-\t\tpci_lock_rescan_remove();\n-\t\tpcibios_remove_pci_devices(bus);\n-\t\tpci_unlock_rescan_remove();\n+\t\tif (pe->type & EEH_PE_VF) {\n+\t\t\teeh_pe_dev_traverse(pe, eeh_rmv_device, NULL);\n+\t\t} else {\n+\t\t\teeh_pe_state_clear(pe, EEH_PE_PRI_BUS);\n+\t\t\tpci_lock_rescan_remove();\n+\t\t\tpcibios_remove_pci_devices(bus);\n+\t\t\tpci_unlock_rescan_remove();\n+\t\t}\n \t} else if (frozen_bus) {\n-\t\teeh_pe_dev_traverse(pe, eeh_rmv_device, &removed);\n+\t\teeh_pe_dev_traverse(pe, eeh_rmv_device, &rmv_data);\n \t}\n \n \t/*\n@@ -610,14 +673,22 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus)\n \t\t * PE. We should disconnect it so the binding can be\n \t\t * rebuilt when adding PCI devices.\n \t\t */\n+\t\tedev = list_first_entry(&pe->edevs, struct eeh_dev, list);\n \t\teeh_pe_traverse(pe, eeh_pe_detach_dev, NULL);\n-\t\tpcibios_add_pci_devices(bus);\n-\t} else if (frozen_bus && removed) {\n+\t\tif (pe->type & EEH_PE_VF)\n+\t\t\teeh_add_virt_device(edev, NULL);\n+\t\telse\n+\t\t\tpcibios_add_pci_devices(bus);\n+\t} else if (frozen_bus && rmv_data->removed) {\n \t\tpr_info(\"EEH: Sleep 5s ahead of partial hotplug\\n\");\n \t\tssleep(5);\n \n+\t\tedev = list_first_entry(&pe->edevs, struct eeh_dev, list);\n \t\teeh_pe_traverse(pe, eeh_pe_detach_dev, NULL);\n-\t\tpcibios_add_pci_devices(frozen_bus);\n+\t\tif (pe->type & EEH_PE_VF)\n+\t\t\teeh_add_virt_device(edev, NULL);\n+\t\telse\n+\t\t\tpcibios_add_pci_devices(frozen_bus);\n \t}\n \teeh_pe_state_clear(pe, EEH_PE_KEEP);\n \n@@ -636,8 +707,10 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus)\n static void eeh_handle_normal_event(struct eeh_pe *pe)\n {\n \tstruct pci_bus *frozen_bus;\n+\tstruct eeh_dev *edev, *tmp;\n \tint rc = 0;\n \tenum pci_ers_result result = PCI_ERS_RESULT_NONE;\n+\tstruct eeh_rmv_data rmv_data = {LIST_HEAD_INIT(rmv_data.edev_list), 0};\n \n \tfrozen_bus = eeh_pe_bus_get(pe);\n \tif (!frozen_bus) {\n@@ -692,7 +765,7 @@ static void eeh_handle_normal_event(struct eeh_pe *pe)\n \t */\n \tif (result == PCI_ERS_RESULT_NONE) {\n \t\tpr_info(\"EEH: Reset with hotplug activity\\n\");\n-\t\trc = eeh_reset_device(pe, frozen_bus);\n+\t\trc = eeh_reset_device(pe, frozen_bus, NULL);\n \t\tif (rc) {\n \t\t\tpr_warn(\"%s: Unable to reset, err=%d\\n\",\n \t\t\t\t__func__, rc);\n@@ -744,7 +817,7 @@ static void eeh_handle_normal_event(struct eeh_pe *pe)\n \t/* If any device called out for a reset, then reset the slot */\n \tif (result == PCI_ERS_RESULT_NEED_RESET) {\n \t\tpr_info(\"EEH: Reset without hotplug activity\\n\");\n-\t\trc = eeh_reset_device(pe, NULL);\n+\t\trc = eeh_reset_device(pe, NULL, &rmv_data);\n \t\tif (rc) {\n \t\t\tpr_warn(\"%s: Cannot reset, err=%d\\n\",\n \t\t\t\t__func__, rc);\n@@ -764,6 +837,15 @@ static void eeh_handle_normal_event(struct eeh_pe *pe)\n \t\tgoto hard_fail;\n \t}\n \n+\t/*\n+\t * For those hot removed VFs, we should add back them after PF get\n+\t * recovered properly.\n+\t */\n+\tlist_for_each_entry_safe(edev, tmp, &rmv_data.edev_list, rmv_list) {\n+\t\teeh_add_virt_device(edev, NULL);\n+\t\tlist_del(&edev->rmv_list);\n+\t}\n+\n \t/* Tell all device drivers that they can resume operations */\n \tpr_info(\"EEH: Notify device driver to resume\\n\");\n \teeh_pe_dev_traverse(pe, eeh_report_resume, NULL);\n@@ -803,12 +885,17 @@ perm_error:\n \t * the their PCI config any more.\n \t */\n \tif (frozen_bus) {\n-\t\teeh_pe_state_clear(pe, EEH_PE_PRI_BUS);\n-\t\teeh_pe_dev_mode_mark(pe, EEH_DEV_REMOVED);\n+\t\tif (pe->type & EEH_PE_VF) {\n+\t\t\teeh_pe_dev_traverse(pe, eeh_rmv_device, NULL);\n+\t\t\teeh_pe_dev_mode_mark(pe, EEH_DEV_REMOVED);\n+\t\t} else {\n+\t\t\teeh_pe_state_clear(pe, EEH_PE_PRI_BUS);\n+\t\t\teeh_pe_dev_mode_mark(pe, EEH_DEV_REMOVED);\n \n-\t\tpci_lock_rescan_remove();\n-\t\tpcibios_remove_pci_devices(frozen_bus);\n-\t\tpci_unlock_rescan_remove();\n+\t\t\tpci_lock_rescan_remove();\n+\t\t\tpcibios_remove_pci_devices(frozen_bus);\n+\t\t\tpci_unlock_rescan_remove();\n+\t\t}\n \t}\n }\n \ndiff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c\nindex e23bdf7..38102cb 100644\n--- a/arch/powerpc/kernel/pci_dn.c\n+++ b/arch/powerpc/kernel/pci_dn.c\n@@ -139,6 +139,7 @@ struct pci_dn *pci_get_pdn(struct pci_dev *pdev)\n #ifdef CONFIG_PCI_IOV\n static struct pci_dn *add_one_dev_pci_data(struct pci_dn *parent,\n \t\t\t\t\t struct pci_dev *pdev,\n+\t\t\t\t\t int vf_index,\n \t\t\t\t\t int busno, int devfn)\n {\n \tstruct pci_dn *pdn;\n@@ -158,6 +159,7 @@ static struct pci_dn *add_one_dev_pci_data(struct pci_dn *parent,\n \tpdn->busno = busno;\n \tpdn->devfn = devfn;\n #ifdef CONFIG_PPC_POWERNV\n+\tpdn->vf_index = vf_index;\n \tpdn->pe_number = IODA_INVALID_PE;\n #endif\n \tINIT_LIST_HEAD(&pdn->child_list);\n@@ -197,7 +199,7 @@ struct pci_dn *add_dev_pci_data(struct pci_dev *pdev)\n \t\treturn NULL;\n \n \tfor (i = 0; i < pci_sriov_get_totalvfs(pdev); i++) {\n-\t\tpdn = add_one_dev_pci_data(parent, NULL,\n+\t\tpdn = add_one_dev_pci_data(parent, NULL, i,\n \t\t\t\t\t pci_iov_virtfn_bus(pdev, i),\n \t\t\t\t\t pci_iov_virtfn_devfn(pdev, i));\n \t\tif (!pdn) {\n", "prefixes": [ "v15", "09/12" ] }