powerpc/eeh: Introduce EEH device
Original EEH implementation depends on struct pci_dn heavily. However,
EEH shouldn't depend on that actually because EEH needn't share much
information with other PCI components. That's to say, EEH should have
worked independently.
The patch introduces struct eeh_dev so that EEH core components needn't
be working based on struct pci_dn in future. Also, struct pci_dn, struct
eeh_dev instances are created in dynamic fasion and the binding with EEH
device, OF node, PCI device is implemented as well.
The EEH devices are created after PHBs are detected and initialized, but
PCI emunation hasn't started yet. Apart from that, PHB might be created
dynamically through DLPAR component and the EEH devices should be creatd
as well. Another case might be OF node is created dynamically by DR
(Dynamic Reconfiguration), which has been defined by PAPR. For those OF
nodes created by DR, EEH devices should be also created accordingly. The
binding between EEH device and OF node is done while the EEH device is
initially created.
The binding between EEH device and PCI device should be done after PCI
emunation is done. Besides, PCI hotplug also needs the binding so that
the EEH devices could be traced from the newly coming PCI buses or PCI
devices.
Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2012-02-28 04:04:04 +08:00
|
|
|
/*
|
|
|
|
* The file intends to implement dynamic creation of EEH device, which will
|
|
|
|
* be bound with OF node and PCI device simutaneously. The EEH devices would
|
|
|
|
* be foundamental information for EEH core components to work proerly. Besides,
|
|
|
|
* We have to support multiple situations where dynamic creation of EEH device
|
|
|
|
* is required:
|
|
|
|
*
|
|
|
|
* 1) Before PCI emunation starts, we need create EEH devices according to the
|
|
|
|
* PCI sensitive OF nodes.
|
|
|
|
* 2) When PCI emunation is done, we need do the binding between PCI device and
|
|
|
|
* the associated EEH device.
|
|
|
|
* 3) DR (Dynamic Reconfiguration) would create PCI sensitive OF node. EEH device
|
|
|
|
* will be created while PCI sensitive OF node is detected from DR.
|
|
|
|
* 4) PCI hotplug needs redoing the binding between PCI device and EEH device. If
|
|
|
|
* PHB is newly inserted, we also need create EEH devices accordingly.
|
|
|
|
*
|
|
|
|
* Copyright Benjamin Herrenschmidt & Gavin Shan, IBM Corporation 2012.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/export.h>
|
|
|
|
#include <linux/gfp.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
|
|
|
|
#include <asm/pci-bridge.h>
|
|
|
|
#include <asm/ppc-pci.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* eeh_dev_init - Create EEH device according to OF node
|
|
|
|
* @dn: device node
|
|
|
|
* @data: PHB
|
|
|
|
*
|
|
|
|
* It will create EEH device according to the given OF node. The function
|
|
|
|
* might be called by PCI emunation, DR, PHB hotplug.
|
|
|
|
*/
|
|
|
|
void * __devinit eeh_dev_init(struct device_node *dn, void *data)
|
|
|
|
{
|
|
|
|
struct pci_controller *phb = data;
|
|
|
|
struct eeh_dev *edev;
|
|
|
|
|
|
|
|
/* Allocate EEH device */
|
2012-09-08 06:44:03 +08:00
|
|
|
edev = kzalloc(sizeof(*edev), GFP_KERNEL);
|
powerpc/eeh: Introduce EEH device
Original EEH implementation depends on struct pci_dn heavily. However,
EEH shouldn't depend on that actually because EEH needn't share much
information with other PCI components. That's to say, EEH should have
worked independently.
The patch introduces struct eeh_dev so that EEH core components needn't
be working based on struct pci_dn in future. Also, struct pci_dn, struct
eeh_dev instances are created in dynamic fasion and the binding with EEH
device, OF node, PCI device is implemented as well.
The EEH devices are created after PHBs are detected and initialized, but
PCI emunation hasn't started yet. Apart from that, PHB might be created
dynamically through DLPAR component and the EEH devices should be creatd
as well. Another case might be OF node is created dynamically by DR
(Dynamic Reconfiguration), which has been defined by PAPR. For those OF
nodes created by DR, EEH devices should be also created accordingly. The
binding between EEH device and OF node is done while the EEH device is
initially created.
The binding between EEH device and PCI device should be done after PCI
emunation is done. Besides, PCI hotplug also needs the binding so that
the EEH devices could be traced from the newly coming PCI buses or PCI
devices.
Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2012-02-28 04:04:04 +08:00
|
|
|
if (!edev) {
|
|
|
|
pr_warning("%s: out of memory\n", __func__);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Associate EEH device with OF node */
|
2012-03-21 05:30:27 +08:00
|
|
|
PCI_DN(dn)->edev = edev;
|
powerpc/eeh: Introduce EEH device
Original EEH implementation depends on struct pci_dn heavily. However,
EEH shouldn't depend on that actually because EEH needn't share much
information with other PCI components. That's to say, EEH should have
worked independently.
The patch introduces struct eeh_dev so that EEH core components needn't
be working based on struct pci_dn in future. Also, struct pci_dn, struct
eeh_dev instances are created in dynamic fasion and the binding with EEH
device, OF node, PCI device is implemented as well.
The EEH devices are created after PHBs are detected and initialized, but
PCI emunation hasn't started yet. Apart from that, PHB might be created
dynamically through DLPAR component and the EEH devices should be creatd
as well. Another case might be OF node is created dynamically by DR
(Dynamic Reconfiguration), which has been defined by PAPR. For those OF
nodes created by DR, EEH devices should be also created accordingly. The
binding between EEH device and OF node is done while the EEH device is
initially created.
The binding between EEH device and PCI device should be done after PCI
emunation is done. Besides, PCI hotplug also needs the binding so that
the EEH devices could be traced from the newly coming PCI buses or PCI
devices.
Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2012-02-28 04:04:04 +08:00
|
|
|
edev->dn = dn;
|
|
|
|
edev->phb = phb;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* eeh_dev_phb_init_dynamic - Create EEH devices for devices included in PHB
|
|
|
|
* @phb: PHB
|
|
|
|
*
|
|
|
|
* Scan the PHB OF node and its child association, then create the
|
|
|
|
* EEH devices accordingly
|
|
|
|
*/
|
|
|
|
void __devinit eeh_dev_phb_init_dynamic(struct pci_controller *phb)
|
|
|
|
{
|
|
|
|
struct device_node *dn = phb->dn;
|
|
|
|
|
|
|
|
/* EEH device for PHB */
|
|
|
|
eeh_dev_init(dn, phb);
|
|
|
|
|
|
|
|
/* EEH devices for children OF nodes */
|
|
|
|
traverse_pci_devices(dn, eeh_dev_init, phb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* eeh_dev_phb_init - Create EEH devices for devices included in existing PHBs
|
|
|
|
*
|
|
|
|
* Scan all the existing PHBs and create EEH devices for their OF
|
|
|
|
* nodes and their children OF nodes
|
|
|
|
*/
|
2012-09-08 06:44:02 +08:00
|
|
|
static int __init eeh_dev_phb_init(void)
|
powerpc/eeh: Introduce EEH device
Original EEH implementation depends on struct pci_dn heavily. However,
EEH shouldn't depend on that actually because EEH needn't share much
information with other PCI components. That's to say, EEH should have
worked independently.
The patch introduces struct eeh_dev so that EEH core components needn't
be working based on struct pci_dn in future. Also, struct pci_dn, struct
eeh_dev instances are created in dynamic fasion and the binding with EEH
device, OF node, PCI device is implemented as well.
The EEH devices are created after PHBs are detected and initialized, but
PCI emunation hasn't started yet. Apart from that, PHB might be created
dynamically through DLPAR component and the EEH devices should be creatd
as well. Another case might be OF node is created dynamically by DR
(Dynamic Reconfiguration), which has been defined by PAPR. For those OF
nodes created by DR, EEH devices should be also created accordingly. The
binding between EEH device and OF node is done while the EEH device is
initially created.
The binding between EEH device and PCI device should be done after PCI
emunation is done. Besides, PCI hotplug also needs the binding so that
the EEH devices could be traced from the newly coming PCI buses or PCI
devices.
Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2012-02-28 04:04:04 +08:00
|
|
|
{
|
|
|
|
struct pci_controller *phb, *tmp;
|
|
|
|
|
|
|
|
list_for_each_entry_safe(phb, tmp, &hose_list, list_node)
|
|
|
|
eeh_dev_phb_init_dynamic(phb);
|
2012-09-08 06:44:02 +08:00
|
|
|
|
2012-09-08 06:44:04 +08:00
|
|
|
pr_info("EEH: devices created\n");
|
|
|
|
|
2012-09-08 06:44:02 +08:00
|
|
|
return 0;
|
powerpc/eeh: Introduce EEH device
Original EEH implementation depends on struct pci_dn heavily. However,
EEH shouldn't depend on that actually because EEH needn't share much
information with other PCI components. That's to say, EEH should have
worked independently.
The patch introduces struct eeh_dev so that EEH core components needn't
be working based on struct pci_dn in future. Also, struct pci_dn, struct
eeh_dev instances are created in dynamic fasion and the binding with EEH
device, OF node, PCI device is implemented as well.
The EEH devices are created after PHBs are detected and initialized, but
PCI emunation hasn't started yet. Apart from that, PHB might be created
dynamically through DLPAR component and the EEH devices should be creatd
as well. Another case might be OF node is created dynamically by DR
(Dynamic Reconfiguration), which has been defined by PAPR. For those OF
nodes created by DR, EEH devices should be also created accordingly. The
binding between EEH device and OF node is done while the EEH device is
initially created.
The binding between EEH device and PCI device should be done after PCI
emunation is done. Besides, PCI hotplug also needs the binding so that
the EEH devices could be traced from the newly coming PCI buses or PCI
devices.
Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2012-02-28 04:04:04 +08:00
|
|
|
}
|
2012-09-08 06:44:02 +08:00
|
|
|
|
|
|
|
core_initcall(eeh_dev_phb_init);
|