Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee2eb3d4 authored by James Morse's avatar James Morse Committed by Rafael J. Wysocki
Browse files

ACPI / APEI: Generalise the estatus queue's notify code



Refactor the estatus queue's pool notification routine from
NOTIFY_NMI's handlers. This will allow another notification
method to use the estatus queue without duplicating this code.

Add rcu_read_lock()/rcu_read_unlock() around the list
list_for_each_entry_rcu() walker. These aren't strictly necessary as
the whole nmi_enter/nmi_exit() window is a spooky RCU read-side
critical section.

in_nmi_queue_one_entry() is separate from the rcu-list walker for a
later caller that doesn't need to walk a list.

Signed-off-by: default avatarJames Morse <james.morse@arm.com>
Reviewed-by: default avatarPunit Agrawal <punit.agrawal@arm.com>
Tested-by: default avatarTyler Baicar <tbaicar@codeaurora.org>
[ rjw: Drop unnecessary err variable in two places ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 5cc6c682
Loading
Loading
Loading
Loading
+41 −22
Original line number Original line Diff line number Diff line
@@ -912,21 +912,14 @@ static void __process_error(struct ghes *ghes)
#endif
#endif
}
}


static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs)
static int ghes_in_nmi_queue_one_entry(struct ghes *ghes)
{
{
	u64 buf_paddr;
	u64 buf_paddr;
	struct ghes *ghes;
	int sev;
	int sev, ret = NMI_DONE;

	if (!atomic_add_unless(&ghes_in_nmi, 1, 1))
		return ret;


	list_for_each_entry_rcu(ghes, &ghes_nmi, list) {
	if (ghes_read_estatus(ghes, &buf_paddr)) {
	if (ghes_read_estatus(ghes, &buf_paddr)) {
		ghes_clear_estatus(ghes, buf_paddr);
		ghes_clear_estatus(ghes, buf_paddr);
			continue;
		return -ENOENT;
		} else {
			ret = NMI_HANDLED;
	}
	}


	sev = ghes_severity(ghes->estatus->error_severity);
	sev = ghes_severity(ghes->estatus->error_severity);
@@ -937,12 +930,38 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs)


	__process_error(ghes);
	__process_error(ghes);
	ghes_clear_estatus(ghes, buf_paddr);
	ghes_clear_estatus(ghes, buf_paddr);

	return 0;
}
}


#ifdef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
static int ghes_in_nmi_spool_from_list(struct list_head *rcu_list)
	if (ret == NMI_HANDLED)
{
	int ret = -ENOENT;
	struct ghes *ghes;

	rcu_read_lock();
	list_for_each_entry_rcu(ghes, rcu_list, list) {
		if (!ghes_in_nmi_queue_one_entry(ghes))
			ret = 0;
	}
	rcu_read_unlock();

	if (IS_ENABLED(CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG) && !ret)
		irq_work_queue(&ghes_proc_irq_work);
		irq_work_queue(&ghes_proc_irq_work);
#endif

	return ret;
}

static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs)
{
	int ret = NMI_DONE;

	if (!atomic_add_unless(&ghes_in_nmi, 1, 1))
		return ret;

	if (!ghes_in_nmi_spool_from_list(&ghes_nmi))
		ret = NMI_HANDLED;

	atomic_dec(&ghes_in_nmi);
	atomic_dec(&ghes_in_nmi);
	return ret;
	return ret;
}
}