aboutsummaryrefslogtreecommitdiff
path: root/hw/p7ioc-phb.c
AgeCommit message (Collapse)AuthorFilesLines
2016-10-24pci: Remove obsoleted PCI slot pfreset() operationGavin Shan1-6/+0
PCI slot pfreset() operation is obsoleted as nobody uses it. This removes it and the related PCI slot states. No functional changes introduced. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Acked-by: Russell Currey <ruscur@russell.cc> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-12pci: Avoid hot resets at boot timeRussell Currey1-2/+2
In the PCI post-fundamental reset code, a hot reset is performed at the end. This is causing issues at boot time as a reset signal is being sent downstream before the links are up, which is causing issues on adapters behind switches. No errors result in skiboot, but the adapters are not usable in Linux as a result. Hot resets also occur in the FSP platform-specific code for conventional PCI slots, which could cause issues. This patch fixes some adapters not being configurable in Linux on some systems. The issue was not present in skiboot 5.2.x. Cc: stable # 5.3.x Signed-off-by: Russell Currey <ruscur@russell.cc> Acked-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-30pci: Standardise on uint64_t pe_numberRussell Currey1-22/+23
Throughout skiboot (and the kernel) PE numbers are named "pe_no", "pe_num" and "pe_number", and sized as 16, 32 and 64bit uints depending on where you look. This is annoying and potentially misleading in cases such as the OPAL API, where different calls have different int sizes even though the PE number they want is the same. Fix this by making *everything* uint64_t pe_number. In doing this, there are some whitespace fixes and mve_number gets dragged into this as well for cases like set_msi_{32/64} where they essentially mean the same thing. Signed-off-by: Russell Currey <ruscur@russell.cc> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-08-11interrupts: Add new source ->attributes callbackBenjamin Herrenschmidt1-11/+14
This allows a given source to provide per-interrupt attributes such as whether it targets OPAL or Linux and it's estimated frequency. The former allows to get rid of the double set of ops used to decide which interrupts go where on some modules like the PHBs and the latter will be eventually used to implement smart caching of the source lookups. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-13interrupts: Expose irq_source and change prototypes of all opsBenjamin Herrenschmidt1-10/+11
This makes irq_source public, and change all irq_source_ops to take the source pointer as a first argument (they can still dig the void * data out of that). This will allow us to embed/wrap it for XIVE later on. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-12interrupts: Use a #interrupt-cells of 2 for XICS interruptsBenjamin Herrenschmidt1-1/+5
This is more compliant with PAPR, it will also allow us to use the second cell for other attributes on P9. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-07-08pci: get_reserved_pe_number() needs to take the PHB as argumentBenjamin Herrenschmidt1-1/+1
The value might be different for different PHB instances Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Acked-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-14hw/p7ioc: Support PHB slotGavin Shan1-687/+447
This refactors functions used for PHB slot management for P7IOC. Also, PHB slots are created before platform's PHB setup hook (platform.pci_setup_phb()). That means the platforms can override the properties or methods of the PHB slot if necessary. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-14core/pci: Return value for struct phb_ops::device_initGavin Shan1-2/+10
This adds @data argument and "int" return value for struct phb_ops:: device_init() so that it can be called in pci_walk_dev() directly to reinitialize the PCI devices behind the specified slot in subsequent patches. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-14core/pci: Extend pci_restore_bridge_buses() for PCI slotGavin Shan1-1/+1
Currently, pci_restore_bridge_buses() restores the assigned bus ranges for all PCI bridges behind the specified PHB. This extends the function and allows doing same thing for the PCI bridges behind the specified slot. The extended functionality is going to be used by PCI hotplug logic in the subsequent patches. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Reviewed-by: Russell Currey <ruscur@russell.cc> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-14core/pci: Fix wrong reserved PE# in enumerationGavin Shan1-0/+6
When scanning to non-existing PCI device, EEH (frozen) error is usually happening. We clear the unexpected frozen PE state after it. The reserved PE number is assumed to be 0 wrongly. So the frozen state on the reserved PE number isn't cleared properly. This introduces struct phb_ops::get_reserved_pe_number() to retrieve the reserved PE number from platforms. Then the EEH frozen state checking and clearing are applied to the reserved PE number. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-06-09p7ioc-phb: Remove logically deadcodeKamalesh Babulal1-2/+1
We exit p7ioc_phb_mmio_enable(), with OPAL_PARAMETER. When enable is >= OPAL_ENABLE_M64_NON_SPLIT. So remove the logically dead code, which handles this condition. Fixes Coverity defect#97826. Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> [stewart@linux.vnet.ibm.com: fix build error] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-05-03PCI: Move PHB lock to generic layerGavin Shan1-24/+4
All kinds of PHBs are maintaining a spinlock. At mean while, the spinlock is acquired or released by backends for phb_ops->lock() or phb_ops->unlock(). There're no difference of the logic on all kinds of PHBs. So it's reasonable to maintain the lock in the generic layer (struct phb). This moves lock from specific PHB to generic one. The spinlock is initialized when the generic PHB is registered in pci_register_phb(). Also, two inline functions phb_{lock, unlock}() are introduced to acquire/release it. No logical changes introduced. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-11-17PCI: use define for wanting dynamic PHB id for pci_register_phbStewart Smith1-1/+1
No functional change, but static analysis showed up the oddity of something that is generally unsigned (opal_id) having a signed value assigned to it. Took the opportunity to use a define to increase readability. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-11-10sparse: Fix many constant is too big warninsg in p7ioc codeStewart Smith1-90/+90
e.g. hw/p7ioc.c:238:41: warning: constant 0x0002000000000000 is so big it is long Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-10-07pci: Use a fixed numbering of PHBs on OPAL and improve log consistencyBenjamin Herrenschmidt1-3/+3
On P8, we calculate the OPAL ID of the PHB as a function of the physical chip number and PHB index on that chip. P7 continues using "allocated" numbers for now. We also consistently print the PHB ID as a 4-digit hex number which facilitates decoding it, and print the chip:index location in the probe code to make it easier to correlate log entries. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> [stewart@linux.vnet.ibm.com: use next_chip rather than get_chip] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-13hw/p7ioc-phb.c: Fix assignment of addrKamalesh Babulal1-1/+0
In p7ioc_err_inject_io32() addr is passed as an argument. Based on its value , we have a conditional check(s). Re-assigning the addr to 0x0ull, make the whole branching check(s) a dead code. Remove the re-assignment of addr, to fix the issue. Fixes Coverity defect#101020. Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> Cc: Gavin Shan <gwshan@linux.vnet.ibm.com> Acked-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-24Fix potential overrun of p7ioc_phb->{tve_hi_cache, tve_hi_cache}Kamalesh Babulal1-1/+1
p7ioc_phb->{tve_hi_cache, tve_hi_cache} are array with upper bound of 128. In p7ioc_map_pe_dma_window(), we check if the range is 1..255, which might overrun the array. Fix it by checking for array index not greater than 127. Fixes Coverity Defect#97847. Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-06-24p7ioc_err_inject_io32() - Fix uninitialized variable warningKamalesh Babulal1-0/+1
Fix uninitialized variable warning in p7ioc_err_inject_io32(). Fixes Coverity defect #97880 Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-05-07eeh: Fix eeh event handlingAlistair Popple1-1/+1
The opal eeh interrupt handlers raise an opal event (OPAL_EVENT_PCI_ERROR) whenever there is some processing required from the OS. The OS then needs to call opal_pci_next_error(...) in a loop passing each phb in turn to clear the event. However opal_pci_next_error(...) clears the event unconditionally meaning it would be possible for eeh events to be cleared without processing them leading to missed events. This patch fixes the problem by keeping track of eeh events on a per-phb basis and only clearing the opal event once all phb eeh events have been cleared. Signed-off-by: Alistair Popple <alistair@popple.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-04-01Remove redundant includes of opal-api.hMichael Ellerman1-1/+0
Now that opal.h includes opal-api.h, there are a bunch of files that include both but don't need to. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-19change direct use of LSH to SETFIELDDan Streetman1-2/+4
In several places, a "bus/device/function" u16 was being directly or'ed into an address using a left-shift. This should be using SETFIELD, especially now that all _LSH have been removed. Change use of BDFN (bus/device/function) field from using plain left-shift to using SETFIELD(). Add proper BDFN field definitions. Signed-off-by: Dan Streetman <ddstreet@ieee.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-19update users of GET/SETFIELD()Dan Streetman1-4/+4
The last two patches updated GETFIELD() and SETFIELD() to no longer require the user to specify the mask and shift of a field, and to remove all _LSH defines and rename any _MASK defines. There are some places where the masks were used directly, where the caller needs to have the _MASK suffix removed. There are also two users of SETFIELD() where the field name still has the _MASK suffix because there is an existing macro with the base name. Change users of SETFIELD() to include the _MASK suffix where needed. Change direct users of any mask to remove the _MASK suffix. Signed-off-by: Dan Streetman <ddstreet@ieee.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-02-06Move skiboot internal things from opal.h to opal-api.hStewart Smith1-0/+1
This is probably not the best collection of things in the world, but it means that opal.h is much closer to being directly usable by an OS. This triggers a bunch of #include fixes throughout the tree. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2014-10-08PCI: Refactor error injectionGavin Shan1-201/+226
The patch refactors the code we had for PCI error injection. It doesn't change the logic: * Rename names of error types and functions according to the comments given by Michael Ellerman when reviewing the kernel counterpart. * Split The backend of error injection for PHB3 and P7IOC to multiple functions to improve code readability. Some logics are simplified without affecting their original functionality. * Misc cleanup like renaming variables and functions. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-08-29PCI: Add pci_device_init()Gavin Shan1-2/+2
The patch adds function pci_device_init(), which is called by phb->ops->device_init() to apply common initialization on the specified PCI device during bootup or after PE reset. Currently, we only put the logic of MPS configuration to the function, but more will be put there. Suggested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-08-08PCI: Restore bus numbers after complete resetGavin Shan1-0/+13
The complete reset could be issued by kdump kernel to remove pending PCI traffic in order to avoid EEH errors in kdump scenario. However, the bus numbers configured into PCI bridges would be lost after the reset and it would cause that some of PCI devices (e.g. IPR) can't be probed by kdump kernel successfully. The patch fixes above issue by restoring bus numbers after complete reset. It's responsing to bug#113210 Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-08-08Use small macros for PHB debug/log messagesStewart Smith1-20/+4
Save stack space, remove code and improve logging all in one handy patch. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-07-21PCI: Allow to set frozen stateGavin Shan1-0/+33
The patch introduces a new OPAL API opal_pci_eeh_freeze_set(), which allows to set frozen state for the specified PE, so that we can support "compound" PE in kernel. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-07-21PCI: Clear PAPR error injectionGavin Shan1-0/+19
Though the p7ioc spec states the errors triggered by PAPR error injection register set (0x2b0, 0x2b8, 0x2c0) should be one-shot without "sticky" bit, Firebird-L machine doesn't follow the rule. It will cause endless frozen PE until we have to remove the PE permanently. The patch extends opal_pci_reset() allowing kernel to clear PAPR error injection register set at appropriate point. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-07-21P7IOC: Support error injectionMike Qiu1-0/+233
The patch implements P7IOC backend to support error injection. There are 3 registers (control, address and mask) for each P7IOC PHB to do error injection. The way to do error injection is straight-forward. For IO, MMIO and PCI-CFG error injection, we check the address is valid or not. The address will be used for error injection if that's valid. Otherwise, we have to figure one out from IODT, M32DT or PELTM. As DMA address is natually invisible to users, we just figure it out from TVT and use that for error injection. 64-bits error injection will be supported later. Signed-off-by: Mike Qiu <qiudayu@linux.vnet.ibm.com> Reviewed-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-07-21P7IOC: Grab PHB versionGavin Shan1-2/+2
We need apply errata based on PHB version in future. So lets grab it at PHB initialization time. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-07-13p7ioc-phb: Remove recursive lockingBenjamin Herrenschmidt1-6/+0
I can't quite figure what this code was trying to do, but I don't see how it would help, phb3_read_phb_status() should already have the right amount of locking in the caller. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
2014-07-02Initial commit of Open Source releaseBenjamin Herrenschmidt1-0/+3206
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>