Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *  Copyright 2006 Michael Ellerman, IBM Corporation
0004  */
0005 
0006 #include <linux/kernel.h>
0007 #include <linux/interrupt.h>
0008 
0009 #include <asm/setup.h>
0010 #include <asm/page.h>
0011 #include <asm/firmware.h>
0012 #include <asm/kexec.h>
0013 #include <asm/xics.h>
0014 #include <asm/xive.h>
0015 #include <asm/smp.h>
0016 #include <asm/plpar_wrappers.h>
0017 
0018 #include "pseries.h"
0019 
0020 void pseries_kexec_cpu_down(int crash_shutdown, int secondary)
0021 {
0022     /*
0023      * Don't risk a hypervisor call if we're crashing
0024      * XXX: Why? The hypervisor is not crashing. It might be better
0025      * to at least attempt unregister to avoid the hypervisor stepping
0026      * on our memory.
0027      */
0028     if (firmware_has_feature(FW_FEATURE_SPLPAR) && !crash_shutdown) {
0029         int ret;
0030         int cpu = smp_processor_id();
0031         int hwcpu = hard_smp_processor_id();
0032 
0033         if (get_lppaca()->dtl_enable_mask) {
0034             ret = unregister_dtl(hwcpu);
0035             if (ret) {
0036                 pr_err("WARNING: DTL deregistration for cpu "
0037                        "%d (hw %d) failed with %d\n",
0038                        cpu, hwcpu, ret);
0039             }
0040         }
0041 
0042         ret = unregister_slb_shadow(hwcpu);
0043         if (ret) {
0044             pr_err("WARNING: SLB shadow buffer deregistration "
0045                    "for cpu %d (hw %d) failed with %d\n",
0046                    cpu, hwcpu, ret);
0047         }
0048 
0049         ret = unregister_vpa(hwcpu);
0050         if (ret) {
0051             pr_err("WARNING: VPA deregistration for cpu %d "
0052                    "(hw %d) failed with %d\n", cpu, hwcpu, ret);
0053         }
0054     }
0055 
0056     if (xive_enabled()) {
0057         xive_teardown_cpu();
0058 
0059         if (!secondary)
0060             xive_shutdown();
0061     } else
0062         xics_kexec_teardown_cpu(secondary);
0063 }
0064 
0065 void pseries_machine_kexec(struct kimage *image)
0066 {
0067     if (firmware_has_feature(FW_FEATURE_SET_MODE))
0068         pseries_disable_reloc_on_exc();
0069 
0070     default_machine_kexec(image);
0071 }