From patchwork Tue May 20 08:30:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 350561 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C135A140086 for ; Tue, 20 May 2014 18:32:59 +1000 (EST) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id A2F3A1A0D2E for ; Tue, 20 May 2014 18:32:59 +1000 (EST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id E34B01A085D for ; Tue, 20 May 2014 18:30:24 +1000 (EST) Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 20 May 2014 18:30:23 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp07.au.ibm.com (202.81.31.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 20 May 2014 18:30:21 +1000 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [9.190.234.120]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id C7E1B357804F for ; Tue, 20 May 2014 18:30:20 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s4K88tRK22610114 for ; Tue, 20 May 2014 18:08:55 +1000 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s4K8UKYC022823 for ; Tue, 20 May 2014 18:30:20 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.190.163.12]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s4K8UJv6022814; Tue, 20 May 2014 18:30:19 +1000 Received: from shangw (haven.au.ibm.com [9.190.164.82]) by ozlabs.au.ibm.com (Postfix) with ESMTP id BFB6EA011B; Tue, 20 May 2014 18:30:19 +1000 (EST) Received: by shangw (Postfix, from userid 1000) id 28AE53E1F36; Tue, 20 May 2014 18:30:20 +1000 (EST) From: Gavin Shan To: kvm-ppc@vger.kernel.org Subject: [PATCH 2/4] powerpc/eeh: Flags for passed device and PE Date: Tue, 20 May 2014 18:30:10 +1000 Message-Id: <1400574612-19411-3-git-send-email-gwshan@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1400574612-19411-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1400574612-19411-1-git-send-email-gwshan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14052008-0260-0000-0000-000004FB3991 Cc: aik@ozlabs.ru, agraf@suse.de, Gavin Shan , alex.williamson@redhat.com, qiudayu@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" The patch introduces new flags for EEH device and PE to indicate that the device or PE has been passed through to guest. In turn, we will deliver EEH errors to guest for further handling, which will be done in subsequent patches. Signed-off-by: Gavin Shan --- arch/powerpc/include/asm/eeh.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h index 7782056..34a2d83 100644 --- a/arch/powerpc/include/asm/eeh.h +++ b/arch/powerpc/include/asm/eeh.h @@ -72,6 +72,7 @@ struct device_node; #define EEH_PE_RESET (1 << 2) /* PE reset in progress */ #define EEH_PE_KEEP (1 << 8) /* Keep PE on hotplug */ +#define EEH_PE_PASSTHROUGH (1 << 9) /* PE owned by guest */ struct eeh_pe { int type; /* PE type: PHB/Bus/Device */ @@ -93,6 +94,21 @@ struct eeh_pe { #define eeh_pe_for_each_dev(pe, edev, tmp) \ list_for_each_entry_safe(edev, tmp, &pe->edevs, list) +static inline bool eeh_pe_passed(struct eeh_pe *pe) +{ + return pe ? !!(pe->state & EEH_PE_PASSTHROUGH) : false; +} + +static inline void eeh_pe_set_passed(struct eeh_pe *pe, bool passed) +{ + if (pe) { + if (passed) + pe->state |= EEH_PE_PASSTHROUGH; + else + pe->state &= ~EEH_PE_PASSTHROUGH; + } +} + /* * The struct is used to trace EEH state for the associated * PCI device node or PCI device. In future, it might @@ -110,6 +126,7 @@ struct eeh_pe { #define EEH_DEV_SYSFS (1 << 9) /* Sysfs created */ #define EEH_DEV_REMOVED (1 << 10) /* Removed permanently */ #define EEH_DEV_FRESET (1 << 11) /* Fundamental reset */ +#define EEH_DEV_PASSTHROUGH (1 << 12) /* Owned by guest */ struct eeh_dev { int mode; /* EEH mode */ @@ -138,6 +155,21 @@ static inline struct pci_dev *eeh_dev_to_pci_dev(struct eeh_dev *edev) return edev ? edev->pdev : NULL; } +static inline bool eeh_dev_passed(struct eeh_dev *dev) +{ + return dev ? !!(dev->mode & EEH_DEV_PASSTHROUGH) : false; +} + +static inline void eeh_dev_set_passed(struct eeh_dev *dev, bool passed) +{ + if (dev) { + if (passed) + dev->mode |= EEH_DEV_PASSTHROUGH; + else + dev->mode &= ~EEH_DEV_PASSTHROUGH; + } +} + /* Return values from eeh_ops::next_error */ enum { EEH_NEXT_ERR_NONE = 0,