aboutsummaryrefslogtreecommitdiff
path: root/core
AgeCommit message (Collapse)AuthorFilesLines
2015-10-14Fix strcat onto uninit string for pci location codeStewart Smith1-0/+2
I don't *think* we've managed to hit this in the wild, although probably largely by accident than anything on purpose. Fix is to just explicitly set it to ''. Fixes: 58ccf6a977ade80e4475d7d350c4c076ab1accad Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-10-08PCI: Introduce config register filterGavin Shan1-0/+53
We have to provide the emulated result for PCI config register access on some devices to eleminate the gap between hardware and software. One example would be the 0x28 (prefetchable memory window upper 32-bits) of the root complex on Naples isn't writable. Linux kernel relies on that to detect 64-bits window successfully. This introduces config register filter to PCI device to eleminate above gap. Each PCI device maintains a list of filters, which are populated when the PCI device is initialized. When PCI config space is accessed, the filter is searched to override the result from user (write) or hardware (read) if necessary. Reported-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com> Suggested-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Tested-by: Vaibhav Jain <vaibhav@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-10-08interrupts: Convert P8 IRQ assignment to functionsAlistair Popple1-1/+85
Interrupts on P8 are currently hard-coded using macros in include/interrupts.h. The new P8NVL processor has an extra PHB meaning it supports 4 PHBs in total which leads to the following assert fail when booting P8NVL based systems: [6614913194,3] register IRQ source overlap ! [6620562844,3] new: 2000..27f7 old: 2000..27f7 [6870377440,0] Assert fail: core/interrupts.c:67:0 This patch converts the existing macros to function calls so that different platforms can support extra PHBs at the expense of a reduced maximum number of chips. Signed-off-by: Alistair Popple <alistair@popple.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-10-08Add unit test for timebase functionsStewart Smith2-0/+57
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-32/+49
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-10-07Fix printf format warningStewart Smith1-1/+1
Fixes: 55ae15b Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-10-07Ensure we run pollers in cpu_wait_job()Stewart Smith1-0/+9
In root causing a bug on AST BMC Alistair found that pollers weren't being run for around 3800ms. This was due to a wonderful accident that's probably about a year or more old where: In cpu_wait_job we have: unsigned long ticks = usecs_to_tb(5); ... time_wait(ticks); While in time_wait(), deciding on if to run pollers: unsigned long period = msecs_to_tb(5); ... if (remaining >= period) { Obviously, this means we never run pollers. Not ideal. This patch ensures we run pollers every 5ms in cpu_wait_job() as well as displaying how long we waited for a job if that wait was >1second. Reported-by: Alistair Popple <alistair@popple.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-30Add opal_boot_complete to debug descriptorJoel Stanley1-0/+3
This tells us when we've entered the host. First use case is knowing if we can can rely on host communication working, such as receiving and acting on an opal_msg. Signed-off-by: Joel Stanley <joel@jms.id.au> Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> [stewart@linux.vnet.ibm.com: use real bit field rather than C bitfield] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-22Ensure reserved memory ranges are exposed correctly to host (fix corrupted ↵Stewart Smith3-14/+26
SLW image) Memory regions in skiboot have an interesting life cycle. First, we get a bunch from the initial device tree or hdat specifying some existing reserved ranges (as well as adding some of our own if they're missing) but we also get ranges for the entirety of RAM. The idea is that we can do node local allocations for per node resources (which we do) and then, just prior to booting linux, we copy the reserved memory regions to expose to linux along with a set of reserver regions to cover the node local allocations. The problem was that mem_range_is_reserved() was wanting subtle different semantics for memory region type than region_is_reserved() provided. That is, we were overriding the meaning of REGION_SKIBOOT_HEAP to mean both "this is reserved by skiboot" *and* "this is a memory region that covers all of memory and will be shrunk to cover just the memory we have allocated for it just before we boot the payload (linux)". So what would happen is we would ask "hey, is the memory holding the SLW image reserved?" and we'd get the answer of "yes" but referring to the memory region that covers the entirety of memory in a NUMA node, *not* meaning our intent of "this will be reserved when we start linux". To fix this, introduce a new memory region type REGION_MEMORY. This has the semantics of a memory region that covers a block of memory that we can allocate from (using local_alloc) and that the part that was allocated will be passed to linux as reserved, but that the entire range will not be reserved. So our new semantics are: - region_is_reservable() is true if the region *MAY* be reserved (i.e. is the regions that cover the whole of memory OR is explicitly reserved) - region_is_reserved() is true if the region *WILL* be reserved (i.e. is explicitly reserved) This way we check that the SLW image is explicitly reserved and if it isn't, we reserve it. Fixes: 58033e44 Acked-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-15PCI: Clear error bits after changing MPSGavin Shan1-3/+19
Chaning MPS on PCI upstream bridge might cause error bits set on downstream endpoints when system boots into Linux as below case shows: host# lspci -vvs 0001:06:00.0 0001:06:00.0 Ethernet controller: Broadcom Corporation \ NetXtreme II BCM57810 10 Gigabit Ethernet (rev 10) : DevSta: CorrErr+ UncorrErr- FatalErr- UnsuppReq+ AuxPwr- TransPend- : CESta: RxErr- BadTLP- BadDLLP- Rollover- Timeout- NonFatalErr+ This clears those error bits in AER and PCIe capability after MPS is changed. With the patch applied, no more error bits are seen. Reported-by: John Walthour <jwalthour@us.ibm.com> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-15opal/hmi: Use prlog instead of printf.Mahesh Salgaonkar1-4/+4
Replace all printf's with prlog in core/hmi.c. Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-15opal: Fix hang in time_wait* calls on HMI for TB errors.Mahesh Salgaonkar2-0/+18
On TOD/TB errors timebase register stops/freezes until HMI error recovery gets TOD/TB back into running state. However, while HMI recovery is in progress there are chances where some code path may invoke time_wait*() calls which depends on running TB value. In an event of TB not moving, time_wait* calls would keep looping resulting into a hang on that CPU. On OpenPower systems we are seeing system hang on TOD/TB errors. The hang is seen inside OPAL HMI handler while invoking prlog/perror(). The reason is, on OpenPower systems prlog/perror() depends on LPC UART console driver to flush log messages to the console. UART read/write calls invoke time_wait_nopoll() inside opb_[read|write]() functions. When TB is in stopped state this causes a hang in prlog/perror() calls. This patch fixes this issue by modifying time_wait_[no]poll() to check for TB validity and return immediately. Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-11slw/timer: SBE based timer supportBenjamin Herrenschmidt3-27/+55
Recent HostBoot & SBE firmware provide a HW timer facility that can be used to implement OPAL timers and thus limit the reliance on the Linux heartbeat. This implements support for it. The side effect is that i2c from Centaurs is now usable. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> [stewart@linux.vnet.ibm.com: fix run-timer unit test] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-11timer: Pass current timer to timer callbacksBenjamin Herrenschmidt2-5/+6
The caller usually has it and it avoids additional mftb() which can be expensive. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> [stewart@linux.vnet.ibm.com: fix run-timer unit test] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-10Remove old, out of date and misplaced commentStewart Smith1-5/+0
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-10move enum ipl_state to hw/fsp/fsp.cStewart Smith1-1/+0
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-10Remove FIXME for using atomics for opal_pending_eventsStewart Smith1-1/+0
The locking code is obviously correct and it's never shown up in a profile - so it's likely fine for a while yet. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-10remove FIXME from opal_trace_entryStewart Smith1-1/+0
We unlikely need this as ASM until somebody finds it to be a problem. So removing the FIXME so that it doesn't show up when grepping for FIXMEs. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-09Fix comparing array to null is always trueStewart Smith1-2/+2
This should be a strlen() comparison instead of comparing the truthiness of an array. This should be safe as everywhere does populate label, if only with an empty string. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-09assert that allocation of node region name succeeedsStewart Smith1-0/+1
Just bailing out this early in boot is perfectly acceptable. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-09Assert that memory allocation succeeds in mem_region_add_dt_reserved_node()Stewart Smith1-0/+2
If we fail to allocate memory at this point in boot, we should just assert, there's really no coming back from not being able to reserve our reserved memory. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-09Fix harmless free() after realloc() in test-malloc.cStewart Smith1-2/+2
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-09platform: Add platform hook for terminate callVasant Hegde1-1/+3
Current abort() call works fine on FSP based system. We need different mechanism on BMC based machine. Hence introduce platform hook for terminate call. Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-09Move FSP specific abort() code to platform layerVasant Hegde2-16/+4
Presently abort() call sets up HID0, triggers attention and finally calls infinite for loop. FSP takes care of collecting required logs and reboots the system. This sequence is specific to FSP machine and it will not work on BMC based machine. Hence move FSP specific code to hw/fsp/fsp-attn.c. Note that this patch adds new parameter to abort call. Hence replaced _abort() by abort() in exception.c so that we can capture file info as well. Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-08trivial run-malloc test fixup that was fooling coverityStewart Smith1-1/+1
although we assert that p2==p, coverity doesn't pick this up, so we get a false positive of a double free. This is trivial to fix just by modifying our test case. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-01pci: Support absence of base location codeBenjamin Herrenschmidt1-7/+11
We support having no base location code in the PHB. In that case we only use the slot label, if it exists, to create the location code. This allows us to support simpler loc codes for OpenPower. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-01pci: Don't create -T location codes on non-FSP machinesBenjamin Herrenschmidt1-1/+5
This is a temporary workaround. We disable the code that adds the "-T" portion of the location code to network devices on non-FSP machines. This code is a bit fragile, and it does incorrect things on dual-slot mezzanines such as the one in Habanero. If we need to support this on OpenPower, we will need to add a concept of sibling slots to the infrastructure to properly handle the numbering. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-09-01pci/fsp: Cleanup slot_infoBenjamin Herrenschmidt1-7/+14
This moves some fields that are specific to the LXVPD mechanism out of the generic pci_slot_info into a private wrapper. Additionally, most fields in pci_slot_info are made signed integers in order to allow them to be set to "-1" which indicates that the field doesn't have a meaningful value, and inhibits creation of the corresponding device-tree property. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-28hmi: Remove unused variable in opal_handle_hmi()Michael Neuling1-2/+1
rc is only used once in opal_handle_hmi(), so let's remove it. Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-26Fix spelling mistakesStewart Smith5-7/+7
See https://github.com/lucasdemarchi/codespel Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-17core/mem_region: Add mem_range_is_reserved()Jeremy Kerr3-0/+260
This change adds a function to check whether a range of memory is covered by one or more reservations. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-17core/mem_region: parse node-style reserved memoryJeremy Kerr1-1/+57
This change adds code to parse node-style memory reservations from the incoming device-tree. If we find a reserved-memory node in either: /reserved-memory/ or /ibm,hostboot/reserved-memory - then we use that in preference to the property-style reservations. We copy those nodes as-is into /reserved-memory in the output tree, to pass-through allow any extra property data that those input nodes contain. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-17core/mem_region: allow pre-existing reserved-memory nodesJeremy Kerr1-4/+7
If the HB device tree provides a top-level reserved-memory node, we'll abort(). We want to be able to handle a pre-populated reserved-memory node in a future change, so handle this case gracefully. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-17core/mem_region: Move reserved-ranges parsing into a separate functionJeremy Kerr1-34/+46
This change moves the property-style reserved-memory parsing code to a separate function. We split dropping the properties into mem_region_add_dt_reserved (before creating the updated range properties), as we need to do that regardless of where the reservations are parsed from. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-17core: Add dt_copyJeremy Kerr1-0/+38
This change adds a new function to copy a device tree node to a new parent. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-14update 'loading kernel' message to 'waiting for kernel'Stewart Smith1-1/+1
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-11fix dump_regs() for hssr0 and hsrr1Stewart Smith1-1/+1
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-08-11Don't try to print symbol when we didn't find oneStewart Smith1-1/+3
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-31fix run-pel.c build after error log entry changesStewart Smith1-1/+1
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-31opal-api: Add OPAL call to handle abnormal reboots.Vipin K Parashar1-0/+39
This patch adds a new OPAL call OPAL_CEC_REBOOT2 which will be used to handle abnormal reboot/termination by kernel host. This call will allow host kernel to pass reboot type and additional debug data which needs to be captured/saved somewhere (for later analysis) before going down. Currently it will support two reboot types (0). normal reboot, that will behave similar to that of opal_cec_reboot() call, and (1). platform error reboot, that will trigger a system checkstop using xscom address and FIR bit information obtained via device-tree property 'ibm,sw-checkstop-fir'. For unsupported reboot type, this call will do nothing and return with OPAL_UNSUPPORTED. In future, we can overload this call to support additional reboot types. Signed-off-by: Vipin K Parashar <vipin@linux.vnet.ibm.com> Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> Reviewed-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-31errorlog: Simplify log calling conventionSamuel Mendoza-Jonas1-48/+84
Remove the callback functionality from log_error() and replace it with the ability to append to a user data section, or add addtional user data sections to an error log. For multiline or otherwise complex logging the convention is now to call opal_elog_create() to obtain a errorlog buffer and use log_append_msg() and log_append_data() to append to the user data section. Additional user data sections can be added to the error log via log_add_section(). The caller is then responsible for calling log_commit(). For simple logs log_simple_error() takes care of creating and committing the error log as before. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-10Introduce memory allocation return value checkKamalesh Babulal1-0/+4
In pci_std_swizzle_irq_map(), check if the memory allocation of interrupt-mask returns a valid pointer before using it. Fixes Coverity defect#97854. Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Cc: Gavin Shan <gwshan@linux.vnet.ibm.com> [stewart@linux.vnet.ibm.com: change to prerror() rather than prlog(DEBUG)] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-10pci_configure_mps fixes: NULL dereference, null check and typoKamalesh Babulal1-4/+4
Chance of phb or pd being NULL is zero, switch to assert. Suggested-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> Cc: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> [stewart@linux.vnet.ibm.com: switched to assert() instead of completely removing the check] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-08fix potential divide by zeroStewart Smith1-0/+4
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-08fix potential integer overflow for giant cpu_max_pirStewart Smith1-1/+1
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-08verify that PIR in init_all_cpus() is within our bounds for cpu_stacks[pir]Stewart Smith1-0/+1
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-07core/interrupts: Fix resource leak in add_opal_interrupts()Kamalesh Babulal1-0/+2
In add_opal_interrupts(), we allocate memory for irqs property. Which is not freed, after property is added. There are chances of irqs begin NULL, as free(NULL) is nop. It's harmless. Fixes Coverity defect#98849. Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-06core: Bound check get_chip()Benjamin Herrenschmidt1-0/+2
If get_chip() is called with a centaur chipID, return NULL rather than access beyond an array boundary Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-06Disable bust_locks for general calls of abort()Alistair Popple2-2/+2
Currently bust_locks is set to true whenever abort() is called. This was done for the lock debugging code which calls abort() as its last step. If there is a locking error there is a good chance parts of the console code will be deadlocked (for example if it has a lock on the scom bus). However busting locks can cause problems, especially now that flash data is being read in parallel as this uses the LPC bus. Instead of getting a nice error message showing where the code aborted it is likely the message will go missing, or it will be garbled by the flash data. So instead of always busting locks make it so they're only busted if they're suspected of being broken. Signed-off-by: Alistair Popple <alistair@popple.id.au> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2015-07-03plat/qemu: Add LPC based RTC supportBenjamin Herrenschmidt1-17/+0
This adds a driver for standard CMOS RTC chips and use it from the QEMU platform. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>