Skip to content

Commit

Permalink
From patchwork series 434664
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox Snowpatch committed Nov 29, 2024
1 parent a85c72f commit 705b089
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 101 deletions.
23 changes: 0 additions & 23 deletions arch/arm/kernel/machine_kexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,29 +127,6 @@ void crash_smp_send_stop(void)
cpus_stopped = 1;
}

static void machine_kexec_mask_interrupts(void)
{
unsigned int i;
struct irq_desc *desc;

for_each_irq_desc(i, desc) {
struct irq_chip *chip;

chip = irq_desc_get_chip(desc);
if (!chip)
continue;

if (chip->irq_eoi && irqd_irq_inprogress(&desc->irq_data))
chip->irq_eoi(&desc->irq_data);

if (chip->irq_mask)
chip->irq_mask(&desc->irq_data);

if (chip->irq_disable && !irqd_irq_disabled(&desc->irq_data))
chip->irq_disable(&desc->irq_data);
}
}

void machine_crash_shutdown(struct pt_regs *regs)
{
local_irq_disable();
Expand Down
31 changes: 0 additions & 31 deletions arch/arm64/kernel/machine_kexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,37 +207,6 @@ void machine_kexec(struct kimage *kimage)
BUG(); /* Should never get here. */
}

static void machine_kexec_mask_interrupts(void)
{
unsigned int i;
struct irq_desc *desc;

for_each_irq_desc(i, desc) {
struct irq_chip *chip;
int ret;

chip = irq_desc_get_chip(desc);
if (!chip)
continue;

/*
* First try to remove the active state. If this
* fails, try to EOI the interrupt.
*/
ret = irq_set_irqchip_state(i, IRQCHIP_STATE_ACTIVE, false);

if (ret && irqd_irq_inprogress(&desc->irq_data) &&
chip->irq_eoi)
chip->irq_eoi(&desc->irq_data);

if (chip->irq_mask)
chip->irq_mask(&desc->irq_data);

if (chip->irq_disable && !irqd_irq_disabled(&desc->irq_data))
chip->irq_disable(&desc->irq_data);
}
}

/**
* machine_crash_shutdown - shutdown non-crashing cpus and save registers
*/
Expand Down
1 change: 0 additions & 1 deletion arch/powerpc/include/asm/kexec.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ struct pt_regs;
extern void kexec_smp_wait(void); /* get and clear naca physid, wait for
master to copy new code to 0 */
extern void default_machine_kexec(struct kimage *image);
extern void machine_kexec_mask_interrupts(void);

void relocate_new_kernel(unsigned long indirection_page, unsigned long reboot_code_buffer,
unsigned long start_address) __noreturn;
Expand Down
22 changes: 0 additions & 22 deletions arch/powerpc/kexec/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,6 @@
#include <asm/setup.h>
#include <asm/firmware.h>

void machine_kexec_mask_interrupts(void) {
unsigned int i;
struct irq_desc *desc;

for_each_irq_desc(i, desc) {
struct irq_chip *chip;

chip = irq_desc_get_chip(desc);
if (!chip)
continue;

if (chip->irq_eoi && irqd_irq_inprogress(&desc->irq_data))
chip->irq_eoi(&desc->irq_data);

if (chip->irq_mask)
chip->irq_mask(&desc->irq_data);

if (chip->irq_disable && !irqd_irq_disabled(&desc->irq_data))
chip->irq_disable(&desc->irq_data);
}
}

#ifdef CONFIG_CRASH_DUMP
void machine_crash_shutdown(struct pt_regs *regs)
{
Expand Down
23 changes: 0 additions & 23 deletions arch/riscv/kernel/machine_kexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,29 +114,6 @@ void machine_shutdown(void)
#endif
}

static void machine_kexec_mask_interrupts(void)
{
unsigned int i;
struct irq_desc *desc;

for_each_irq_desc(i, desc) {
struct irq_chip *chip;

chip = irq_desc_get_chip(desc);
if (!chip)
continue;

if (chip->irq_eoi && irqd_irq_inprogress(&desc->irq_data))
chip->irq_eoi(&desc->irq_data);

if (chip->irq_mask)
chip->irq_mask(&desc->irq_data);

if (chip->irq_disable && !irqd_irq_disabled(&desc->irq_data))
chip->irq_disable(&desc->irq_data);
}
}

/*
* machine_crash_shutdown - Prepare to kexec after a kernel crash
*
Expand Down
3 changes: 3 additions & 0 deletions include/linux/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,9 @@ extern int irq_chip_request_resources_parent(struct irq_data *data);
extern void irq_chip_release_resources_parent(struct irq_data *data);
#endif

/* Shut down the interrupt */
extern void irq_shutdown(struct irq_desc *desc);

/* Handling of unhandled and spurious interrupts: */
extern void note_interrupt(struct irq_desc *desc, irqreturn_t action_ret);

Expand Down
2 changes: 2 additions & 0 deletions include/linux/kexec.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ extern void machine_kexec(struct kimage *image);
extern int machine_kexec_prepare(struct kimage *image);
extern void machine_kexec_cleanup(struct kimage *image);
extern int kernel_kexec(void);
extern void machine_kexec_mask_interrupts(void);

extern struct page *kimage_alloc_control_pages(struct kimage *image,
unsigned int order);

Expand Down
1 change: 0 additions & 1 deletion kernel/irq/internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ extern int irq_activate(struct irq_desc *desc);
extern int irq_activate_and_startup(struct irq_desc *desc, bool resend);
extern int irq_startup(struct irq_desc *desc, bool resend, bool force);

extern void irq_shutdown(struct irq_desc *desc);
extern void irq_shutdown_and_deactivate(struct irq_desc *desc);
extern void irq_enable(struct irq_desc *desc);
extern void irq_disable(struct irq_desc *desc);
Expand Down
30 changes: 30 additions & 0 deletions kernel/kexec_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#include <linux/hugetlb.h>
#include <linux/objtool.h>
#include <linux/kmsg_dump.h>
#include <linux/irqdesc.h>
#include <linux/irq.h>

#include <asm/page.h>
#include <asm/sections.h>
Expand Down Expand Up @@ -1072,3 +1074,31 @@ int kernel_kexec(void)
kexec_unlock();
return error;
}

void machine_kexec_mask_interrupts(void)
{
unsigned int i;
struct irq_desc *desc;

for_each_irq_desc(i, desc) {
struct irq_chip *chip;
int check_eoi = 1;

chip = irq_desc_get_chip(desc);
if (!chip || !irqd_is_started(&desc->irq_data))
continue;

if (IS_ENABLED(CONFIG_ARM64)) {
/*
* First try to remove the active state. If this fails, try to EOI the
* interrupt.
*/
check_eoi = irq_set_irqchip_state(i, IRQCHIP_STATE_ACTIVE, false);
}

if (check_eoi && chip->irq_eoi && irqd_irq_inprogress(&desc->irq_data))
chip->irq_eoi(&desc->irq_data);

irq_shutdown(desc);
}
}

0 comments on commit 705b089

Please sign in to comment.