From patchwork Fri May 15 13:36:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 6414191 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 73480C0432 for ; Fri, 15 May 2015 13:40:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 81A53204D9 for ; Fri, 15 May 2015 13:40:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 93F4B204D1 for ; Fri, 15 May 2015 13:40:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422676AbbEONkC (ORCPT ); Fri, 15 May 2015 09:40:02 -0400 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:44594 "EHLO e23smtp03.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934540AbbEONkB (ORCPT ); Fri, 15 May 2015 09:40:01 -0400 Received: from /spool/local by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 May 2015 23:39:59 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 15 May 2015 23:39:57 +1000 Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id E30F32CE8040 for ; Fri, 15 May 2015 23:39:56 +1000 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t4FDdmdB14745840 for ; Fri, 15 May 2015 23:39:56 +1000 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t4FDdOfA011448 for ; Fri, 15 May 2015 23:39:24 +1000 Received: from localhost ([9.123.251.150]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t4FDdNF3011201; Fri, 15 May 2015 23:39:23 +1000 From: Wei Yang To: gwshan@linux.vnet.ibm.com, bhelgaas@google.com Cc: linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, Wei Yang Subject: [PATCH V5 05/10] powerpc/powernv: create/release eeh_dev for VF Date: Fri, 15 May 2015 21:36:59 +0800 Message-Id: <1431697024-5710-6-git-send-email-weiyang@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1431697024-5710-1-git-send-email-weiyang@linux.vnet.ibm.com> References: <1431697024-5710-1-git-send-email-weiyang@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15051513-0009-0000-0000-00000165D945 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP EEH on powerpc platform needs eeh_dev structure to track the PCI device status. Since VFs are created/released dynamically, VF's eeh_dev is also dynamically created/released in system. This patch creates/removes eeh_dev when pci_dn is created/removed for VFs, and marks it with EEH_DEV_VF type. Signed-off-by: Wei Yang Acked-by: Gavin Shan --- arch/powerpc/include/asm/eeh.h | 1 + arch/powerpc/kernel/eeh.c | 4 ++++ arch/powerpc/kernel/pci_dn.c | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h index a52db28..1b3614d 100644 --- a/arch/powerpc/include/asm/eeh.h +++ b/arch/powerpc/include/asm/eeh.h @@ -138,6 +138,7 @@ struct eeh_dev { struct pci_controller *phb; /* Associated PHB */ struct pci_dn *pdn; /* Associated PCI device node */ struct pci_dev *pdev; /* Associated PCI device */ + struct pci_dev *physfn; /* Associated PF PORT */ struct pci_bus *bus; /* PCI bus for partial hotplug */ }; diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c index 6c7ce1b..221e280 100644 --- a/arch/powerpc/kernel/eeh.c +++ b/arch/powerpc/kernel/eeh.c @@ -1135,6 +1135,10 @@ void eeh_add_device_late(struct pci_dev *dev) } edev->pdev = dev; +#ifdef CONFIG_PCI_IOV + if (dev->is_virtfn) + edev->physfn = dev->physfn; +#endif dev->dev.archdata.edev = edev; if (eeh_has_flag(EEH_PROBE_MODE_DEV)) diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c index f771130..0469247 100644 --- a/arch/powerpc/kernel/pci_dn.c +++ b/arch/powerpc/kernel/pci_dn.c @@ -180,6 +180,7 @@ static struct pci_dn *add_one_dev_pci_data(struct pci_dn *parent, struct pci_dn *add_dev_pci_data(struct pci_dev *pdev) { #ifdef CONFIG_PCI_IOV + struct pci_controller *hose = pci_bus_to_host(pdev->bus); struct pci_dn *parent, *pdn; int i; @@ -206,6 +207,7 @@ struct pci_dn *add_dev_pci_data(struct pci_dev *pdev) __func__, i); return NULL; } + eeh_dev_init(pdn, hose); } #endif /* CONFIG_PCI_IOV */ @@ -254,10 +256,17 @@ void remove_dev_pci_data(struct pci_dev *pdev) for (i = 0; i < pci_sriov_get_totalvfs(pdev); i++) { list_for_each_entry_safe(pdn, tmp, &parent->child_list, list) { + struct eeh_dev *edev; if (pdn->busno != pci_iov_virtfn_bus(pdev, i) || pdn->devfn != pci_iov_virtfn_devfn(pdev, i)) continue; + edev = pdn_to_eeh_dev(pdn); + if (edev) { + pdn->edev = NULL; + kfree(edev); + } + if (!list_empty(&pdn->list)) list_del(&pdn->list);